dart - 在列中放置一个小部件会在布局期间为 RenderIndexedStack 对象提供无限大小
问题描述
我将以下内容放在这样的列中
Widget _getDropDownCombo()
{
Widget combo = new DropdownButton(
value: _currentItem,
items:_dropDownMenuItems,
onChanged: _changedDropDownItem
);
return Flexible(child:combo);
}
并且 _getDropDownCombo
在这样的地方被连续调用
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
_getDropDownCombo(),
getIcon(),
],)
这给了我错误颤振:══╡通过渲染库╞═══════════════════════════════════ ═══════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: RenderIndexedStack object was given an infinite size during layout.
flutter: This probably means that it is a render object that tries to be as big as possible, but it was put
flutter: inside another render object that allows its children to pick their own size.
flutter: The nearest ancestor providing an unbounded width constraint is:
flutter: RenderFlex#dfcbf relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT
为什么 DropDownButton 会出现此错误?有什么建议么 ?
解决方案
由于 DropdownButton 中的项目,它们可能是问题。我试过在项目中使用它,它工作得很好:
items: ['Foo', 'Bar'].map((String value) {
return new DropdownMenuItem(
value: value,
child: new Text(value),
);
}).toList(),
推荐阅读
- java - 使用 for 循环索引获取可绘制对象
- mongodb - 在 MongoDB 中获取第一个创建的文档并按字段名分组
- logging - kubernetes nginx 入口控制器禁用 HTTP 200 日志
- pydev - 检测到像恶意软件 #9474 一样的 inject_dll_x86.exe
- javascript - finally 子句不适用于 Angular JS 1.7
- deployment - 如何在不每天创建新版本的情况下在舞台上安排部署?
- r - 为什么函数 boot 返回的值与 boot 内部使用的统计数据类型不同?
- codeigniter - 如何在不在 url 中传递敏感信息的情况下访问 codeigniter 根目录之外的文件夹?
- node.js - ENV 变量未加载到构建生产中
- python - 在 Python 中使用 sftp.put 将匹配/通配符文件发送到另一台服务器