flutter - 设置溢出 TextOverflow.ellipsis 文本长度 Flutter
问题描述
如何设置溢出的长度:TextOverflow.ellipsis 因为它截断了您在 img 中看到的文本。文本“这是第一个......”和数字“#1520”之间有一个空格。溢出会截断“第一个...”单词之后的文本。
我希望“现在卡”字样将显示在行中。怎么解决?,谢谢
Container(
color: Colors.grey,
child: ListTile(
title: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text('This is the first card now its time sad sad sad sads ad sdsadsads dsa dsad asdasdasd', overflow: TextOverflow.ellipsis, style: TextStyle(color: Colors.white),)),
Flexible(child: Text('#1520', overflow: TextOverflow.ellipsis, style: TextStyle(color: Colors.white),)),
],
),
),
),
),
我不希望我的所有文字都可见,我只想在一行中显示一些单词。如果您查看 img,您会看到文本和 #1520 之间有一个空白区域。我想使用溢出显示:这是现在的第一张卡片.. #1520
解决方案
- 如果您希望所有文本都可见,只需从文本小部件中删除溢出属性。
- 如果要将文本限制为某些行,请添加带有溢出的 maxLines 属性。像这样
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Flexible(child: Text("This is the first card now its time sad sad sad sads ad sdsadsads dsa dsad asdasdasd", maxLines: 2, overflow: TextOverflow.ellipsis,)),
Flexible(child: Text("#1520"))
],
),
推荐阅读
- r - ggpredict 错误:未为此 S4 类定义 $ 运算符
- python - 根据列表列表的长度为字典创建键
- shell - xargs -a [file] mv -t [new-directory] 给我 mv: cannot stat `filename*': No such file or directory 错误
- html - Bootstrap 4 - 创建居中和等宽的弹性项目
- asp.net-core - 找不到类型或命名空间名称“IWebHostEnvironment”(您是否缺少 using 指令或程序集引用?)
- html - 为什么溢出时垂直滚动条附加到HTML:滚动分配给正文?
- android - Android/Nativescript - 将着色器效果应用于正在播放的视频
- javascript - 如何从数组中获得真正的随机数?还是我应该完全做其他事情?
- amazon-web-services - AWS 中转网关路由
- django - Django 2.2 默认登录网址