gpt4 book ai didi

flutter - 使用Expanded或Flexible和ListTile溢出仍超过32像素

转载 作者:行者123 更新时间:2023-12-03 04:21:26 25 4
gpt4 key购买 nike

无论我使用Wrap而不是Row。灵活或扩展也不起作用?

enter image description here

return ListTile(
contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
dense: true,
title: Row(
children: <Widget>[
Icon(icon),
Padding(
padding: EdgeInsets.only(left: 8.0, top: 0.0, bottom: 0.0),
child: Expanded(
child: Text(
googleplace.address,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
)
],
),
onTap: onTap,
);

最佳答案

ListTile已经可以使用图标和文本而不将其包装在Row小部件中

return ListTile(
contentPadding: EdgeInsets.zero,
dense: true,
leading: Icon(icon), // put your icon here
title: Text(
googleplace.address,
maxLines: 1,
softWrap: true,
overflow: TextOverflow.ellipsis,
),
onTap: onTap,
);

同样在代码中,如果您希望该行正确检测到展开式广告,则应首先使用Expandable Widget,然后使用padding
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 8.0, top: 0.0, bottom: 0.0),
child: Text(
googleplace.address,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
)
),

但我建议您选择第一个选项,ListTile已经具有尾随的和领先的内置小部件,可以帮助您实现所需的功能

关于flutter - 使用Expanded或Flexible和ListTile溢出仍超过32像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62416556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com