【问题标题】:My text widget overflows even if I use the overflow property即使我使用溢出属性,我的文本小部件也会溢出
【发布时间】:2020-05-15 09:19:46
【问题描述】:

我尝试在一行内显示一个文本小部件,但有些句子太长。我不知道如何将它们包装到下一行。

Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20)
        ),
        child: Center(
          child: Row(
            children: <Widget>[
              Image.network(imageUrl, height: 100, width: 100, fit: BoxFit.fill,),
              Text(title, maxLines: 5, softWrap: true, overflow: TextOverflow.fade,textHeightBehavior: ,)
            ],
          ),
        ),
      ),

这是我的代码。

这是我得到的错误。我需要将文本换行到下一行而不会溢出。

【问题讨论】:

    标签: android ios flutter dart flutter-layout


    【解决方案1】:

    将您的 Text 小部件包装在 Expanded 小部件中

    试试这个

     Container(
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(20)
                            ),
                            child: Center(
                              child: Row(
                                children: <Widget>[
                                  Image.network(imageUrl, height: 100, width: 100, fit: BoxFit.fill,),
                                  Expanded(child: Text(title, maxLines: 5, softWrap: true, overflow: TextOverflow.fade,textHeightBehavior: ,))
                                ],
                              ),
                            ),
                          ),
    

    【讨论】:

      猜你喜欢
      • 2020-07-09
      • 2011-10-10
      • 2021-09-27
      • 1970-01-01
      • 2021-01-02
      • 1970-01-01
      • 1970-01-01
      • 2019-02-18
      • 1970-01-01
      相关资源
      最近更新 更多