如何解决如何意识到这一点?
我看到有一个 TrackWidget
的 ListView。
TrackWidget 包含一个 Row,其中有 Text(number)、Text(title)、Text(subtitle)、Text(time) 和 Button。
但是, 也可能存在大于行大小的标题。在这种情况下,Text(title) 应该占据所有位置。
请帮帮我。
解决方法
使用 RichText
小部件可能是可行的方法,使用它,优先呈现的文本将是第一个,因此在您的情况下是歌曲标题。
当文本太长时,也不要忘记将 TextOverflow.ellipsis
设置为 ...
。
示例
ListTile(
leading: Text(songTrackNumber,style: TextStyle(color: Colors.grey)),title: RichText(
overflow: TextOverflow.ellipsis,text: TextSpan(
style: TextStyle(color: Colors.black),children: [
TextSpan(text: songTitle),TextSpan(text: songAlbum,],),trailing: Text(songLength,);
,
Text
小部件看起来像是在使用一种技术来创建椭圆。假设您有下面的 Row
小部件:
Row(
children: [
Text('Row 1,Text 1',style: TextStyle(fontSize: 24,color: Colors.red)),SizedBox(width: 8),Text('Row 1,Text 2',color: Colors.orange)),// This is the widget/text you want to change format. ?
Text('Row 1,Text 3',color: Colors.yellow)),Text 4',color: Colors.green)),);
您需要将该小部件包装在 Container
中,然后将 Container
包装在 Flexible
小部件中。最后向 Text
小部件添加省略号溢出。
像这样:
Row(
children: [
Text('Row 1,/// Our new updated widget.
Flexible(
child: Container(
child: Text(
'Row 1,overflow: TextOverflow.ellipsis,color: Colors.yellow),);
查看 Dart Pad 演示 here。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。