string - [FLUTTER]:根据 ListTile 的高度剪切文本
问题描述
我有以下小部件。问题是我需要根据ListTile
. 现在,高度ListTile
取决于我拥有的子字符串的长度。更长的是我的子字符串,更长的是ListTile
. 看起来很尴尬。放入小部件是好的,但子字符串与下一个ListTile
内容重叠。它看起来也很糟糕。我想,另一个解决方案是使用。但是,我需要每个的固定大小,而不改变fontSize。这就是为什么不适合我:) 它改变了字体大小。当它到达. 我该如何解决这个问题?Container
ListTile
FittedBox
ListTile
FixedBox
ListTile
InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ProductScreen(product),
),
);
},
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 4.0,
),
child: ListTile(
title: Text(
product.title.toUpperCase(),
style: Styles.listTitleStyle,
),
subtitle: Text(
product.description,
style: Styles.listBodyStyle,
),
),
),
const Divider(height: 1.0),
],
解决方案
为您的文本小部件添加类似这样的内容,
subtitle: Text(
maxLines: 2, //customize your number of lines
overflow: TextOverflow.ellipsis, //add this to set (...) at the end of sentence
product.description,
style: Styles.listBodyStyle,
),
推荐阅读
- javascript - 覆盖默认值
- python - TypeError:传入 *args 时参数有多个值
- javascript - 在新的 _blank 选项卡上异步设置 location.href 在 MS Edge 上不起作用
- r - 为闪亮的 Web 应用程序运行 UI 时出错 - 'closure' 类型的对象不是子集
- java - 无法在 Spring Boot 多模块应用程序中的 JUnit 4 测试中自动装配服务
- python - 如何清理此数据类型对象并将其转换为浮点类型
- java - OpenGL / LWJGL如何在移动相机时将对象保持在屏幕中间
- c++ - 如何检测屏幕分辨率何时发生变化?
- python - 如何在 Flask 应用程序中对 HTML 表格进行排序?
- c# - Windows 窗体 - 此上下文中不存在名称“dataGridView2”