flutter - 被 18 像素抖动溢出
问题描述
溢出 18 个像素的 RenderFlex
你好,我是新来的颤振。我正在做一些颤动的项目,但我对这个小部件有一些问题,当我添加一个 FlatButton 时,我得到了 18 个像素的右溢出。你能帮助我吗?
我的代码:
Widget _drawFooter() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FlatButton(
onPressed: () {},
child: Text(
'10 COMMENTS',
style: _hashTagStyle,
),
),
Row(
children: [
IconButton(
icon: Icon(Icons.favorite),
onPressed: () {},
color: Colors.grey.shade400,
),
Text('Open'),
],
),
],
),
Expanded(
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FlatButton(
onPressed: () {},
child: Text(
'SHARE',
style: _hashTagStyle,
),
),
FlatButton(
onPressed: () {},
child: Text(
'OPEN',
style: _hashTagStyle,
),
),
/* FlatButton(
onPressed: () {},
child: Text(
'Open',
style: _hashTagStyle,
),
),*/
// Text('Open'),
],
),
),
],
);
}
}
这是屏幕截图错误:
解决方案
您可以使用 wrap 而不是 row。这是代码:
wrap(
children: [
FlatButton(
onPressed: () {},
child: Text(
'10 COMMENTS',
style: _hashTagStyle,
),
),
Row(
children: [
IconButton(
icon: Icon(Icons.favorite),
onPressed: () {},
color: Colors.grey.shade400,
),
Text('Open'),
],
),
FlatButton(
onPressed: () {},
child: Text(
'SHARE',
style: _hashTagStyle,
),
),
FlatButton(
onPressed: () {},
child: Text(
'OPEN',
style: _hashTagStyle,
),
),
],
),
],
)
这对我有用。欲了解更多详情,请访问此网站。
推荐阅读
- java - 如何修复最常见的 LazyInitializationException - Hibernate JPA
- django - 如何设置错误报告以归档而不是电子邮件
- python - argsparse 组互斥
- django - 在 heroku 上,celery beat 数据库调度程序不运行定期任务
- java - 为什么clone()函数在构造函数中赋值时会显示不兼容的类型?
- python - 如何抓取基于 word press 的页面?分别如何登录请求用户名和密码的页面
- java - 使用 cURL 从我的 API 获取 XML 和 JSON 数据
- intel - 操作系统开发:尝试启用分页时出现三重故障
- c++ - Xcode 调试器只显示一些变量的值。如何纠正这种行为?
- opencv - Red Hat 7 中的机器人框架 Sikuli 库安装缺少“opencv_java”库