gpt4 book ai didi

Flutter:让 Text in Text 小部件在新行溢出

转载 作者:行者123 更新时间:2023-12-02 00:13:46 24 4
gpt4 key购买 nike

我有一个文本小部件,我在其中放置了一些文本(游戏标题),但有些游戏标题达到了屏幕的最大宽度(右侧溢出 77 像素的 RenderFlex。 为例子)。我怎样才能让文本继续在下面?

问题:

enter image description here

我想要这样:

|Im a very long title |
|that does not fit. |

编辑:

Text 小部件位于 Row 小部件中,该小部件存在于 Column 小部件中。

最佳答案

Row(
children: <Widget>[
SomeOtherWidget(),
Expanded( // add this
child: Text(
"This is a long text",
maxLines: 2, // you can change it accordingly
overflow: TextOverflow.ellipsis, // and this
),
),
],
)

Expanded 包装您的 Text 并设置 overflow 属性。

关于Flutter:让 Text in Text 小部件在新行溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57741174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com