如果字符串的长度是动态的,如何包装文本?颤动



我正在创建一个flutter视图,其中用户的位置显示为:

Padding(
padding: const EdgeInsets.only(
right: 14, left: 14, bottom: 8, top: 8),
child: Row(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
Text(
AppLocalizations.of('PICKUP'),
style: Theme
.of(context)
.textTheme
.caption!
.copyWith(
color: Theme
.of(context)
.disabledColor,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 4,
),
Text(
AppLocalizations.of(
'${list[index]['from']}'),
style: Theme
.of(context)
.textTheme
.subtitle2!
.copyWith(
fontWeight: FontWeight.bold,
color: Theme
.of(context)
.textTheme
.headline6!
.color,
),
),
],
),
],
),
),

这里的数据来自包含地址的sql服务器。有时地址很长,所以它只显示一些单词,其余的单词溢出。

每当有长地址时,我想要的东西都会包装到下一行。但我不知道如何实现,因为我是个新手。有人能帮忙吗。提前感谢<3.

您可以在灵活小部件中包装文本

Flexible(
child: 
Text(
AppLocalizations.of(
'${list[index]['from']}'),
style: Theme
.of(context)
.textTheme
.subtitle2!
.copyWith(
fontWeight: FontWeight.bold,
color: Theme
.of(context)
.textTheme
.headline6!
.color,
),
),
)

您也可以使用此软件包:https://pub.dev/packages/auto_size_text用于管理文本大小。

在Flexible小部件中包装文本小部件。您也可以检查此链接的文本溢出问题。

Padding(
padding:const EdgeInsets.all(0)
child:Text("your String")
);

最新更新