flutter - ListTile 子标题 renderflex 溢出
问题描述
我有这样的 ListTile 字幕:
subtitle:Flexible(flex:1,child:Row(children: [
(widget.condiments!=null)?Padding(
child:Text(condimentList,style: TextStyle(color:Colors.grey)),
padding: EdgeInsets.only(top: 10)):null,
])),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(Icons.delete))])
我收到以下错误:
A RenderFlex overflowed by 244 pixels on the right.
The relevant error-causing widget was
Row
我希望将它包裹在灵活的周围应该可以做到,但似乎我不太知道如何解决它。
解决方案
只需将您的文本包装在 Expanded 中即可,无需使用换行。
在dartpad上检查 UI 输出。
ListTile(
title: const Text('Test'),
trailing: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
IconButton(onPressed: () {}, icon: const Icon(Icons.delete))
]),
subtitle: Row(children: const [
Expanded(
child: Padding(
padding: EdgeInsets.all(5),
child: Text(
'This is a test & this will have a very long paragragh to check the errors once. This is a test & this will have a very long paragragh to check the errors once.',
),
))
]),
);
扩展后的 UI 输出:
未展开的 UI 输出:
推荐阅读
- logging - 我需要添加哪个目标功能才能在 RCP 应用程序中进行跟踪?
- php - PHP Foreach 循环回显错误的 Bootstrap 表结构
- python - 如何根据特定列的公共值的条件选择行?
- python - 在 Python 中一次迭代处理 3 行 csv
- jinja2 - dbt jinja 返回查询结果
- python - TF-IDF 计算上的名称定义
- powershell - 使用 Powershell 将磁盘映射到启动器
- java - 使用对象和类时出现“找不到主方法”错误
- javascript - 为什么 getDay() 返回错误的星期几?
- android - Android On Demand 交付数据绑定