我试图使用TextOverflow.Ellipsis来确保某些文本数据不会导致溢出错误。唯一的问题是它似乎不适合我。我添加了属性,但是文本没有被缩短,仍然会导致溢出错误。有谁知道为什么会发生这种情况,以及如何解决?
这就是它目前的样子。即使添加了省略号。

这是将其全部呈现的代码。
Expanded(
flex: 3,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(top: 13, left: 10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(mileage[index].trippurpose,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black,
fontFamily: 'Montserrat'),
overflow: TextOverflow.ellipsis,
softWrap: false,
textAlign: TextAlign.center)
],
)),
Padding(
padding: EdgeInsets.only(left: 10),
child: Row(
children: [
Text(
'${mileage[index].tripfrom} - ',
style: TextStyle(
color: Colors.black,
fontStyle: FontStyle.italic),
),
Padding(
padding: EdgeInsets.only(right: 36),
child: Text(
mileage[index].tripto,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.black,
fontStyle: FontStyle.italic
),
),
)
],
),
),
],
),),发布于 2020-10-30 03:10:10
首先,我总是在这种布局中将maxLines: 1属性添加到Text小部件中。
然后..。
如果可以,请尝试删除小部件.。
如果无法删除
Row小部件与Expanded小部件包装在一起。https://stackoverflow.com/questions/64602055
复制相似问题