使用 FittedBox 時,與文本長度相比,文本大小變得非常小。我不希望文字縮小。相反,我希望文本保持相同的大小,并且只適合可以適合的部分。
Container(
width: 250,
child: Text("Data will end with ... instead of shrinking..."),),
uj5u.com熱心網友回復:
為了使您的文本以這種方式作業,您應該設定文本在溢位時的行為方式。
您需要做的是將overflow屬性設定為TextOverflow.ellipsis:
Text(
'Hello, Test! How are you?',
overflow: TextOverflow.ellipsis,
)
它在Text小部件的 Flutter 檔案中提供:https ://api.flutter.dev/flutter/widgets/Text-class.html 。
另外,檢查其他文本溢位選項:https ://api.flutter.dev/flutter/painting/TextOverflow.html
uj5u.com熱心網友回復:
您可以使用Flexible
Container(
child: Row(
children: [
Flexible(child: Text("A looooooooooooooooooong text"))
],
),
),
有關Flexible檢查
的更多資訊https://api.flutter.dev/flutter/widgets/Flexible-class.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/433718.html
上一篇:如何去除json資料抖動
