简体   繁体   English

Flutter 如何在 Wrap 小部件中制作 Text 小部件,从前一个小部件的末尾开始,而不是从前一个小部件开始?

[英]Flutter How to make a Text widget in a Wrap widget start from the end of the previous widget and not start bellow the previous widget?

I'm trying to make a complete the sentence user interface that may overflow to the next line like this example:我正在尝试制作一个完整的句子用户界面,它可能会溢出到下一行,如下例所示:

在此处输入图片说明

Here is my code:这是我的代码:

 Wrap(
   spacing: 0.8,
   runSpacing: 4.0,
   children: <Widget>[
     new Text('Alpha '),
     new Container(
       width: 50,
       height: 19,
       child: new TextField(
          style: new TextStyle(
              fontSize: 16.0,
              color: Colors.blue,
          ),
       ),
     ),
     new Text(' charlie all the node in jank list is out of time all the node in jank list is out of time',)
   ],
 )

This is the current outcome:这是目前的结果:
在此处输入图片说明

How do I get the second string to start from the end of the TextField and overflow to the next line?如何让第二个字符串从 TextField 的末尾开始并溢出到下一行?

Thanks for the help!谢谢您的帮助!

Really interesting question and quite challenging, I found a solution by using Text rich and text span to achieve it.非常有趣的问题并且非常具有挑战性,我通过使用富文本和文本跨度来实现它找到了一个解决方案。 Hope it helps!希望能帮助到你!

在此处输入图片说明

          Text.rich(
            TextSpan(
              text: 'Alpha ',
              style: TextStyle(color: Colors.black),
              children: <InlineSpan>[
                WidgetSpan(
                  alignment: PlaceholderAlignment.baseline,
                  baseline: TextBaseline.alphabetic,
                  child: Container(
                    width: 50,
                    height: 19,
                    child: TextField(
                      style: TextStyle(
                        fontSize: 16.0,
                        color: Colors.blue,
                      ),
                    ),
                  ),
                ),
                TextSpan(
                  text:
                      ' charlie all the node in jank list is out of time all the node in jank list is out of time',
                ),
              ],
            ),
          ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM