在窗口小部件中放置小部件可使RenderIndexedStack对象在布局期间获得无限大小

时间:2019-01-26 01:59:00

标签: dart flutter

我将以下内容放置在这样的列中

   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出现此错误?有什么建议吗?

1 个答案:

答案 0 :(得分:0)

由于DropdownButton中的项目,它们可能有问题。 我尝试在项目中使用它,并且效果很好:

items: ['Foo', 'Bar'].map((String value) {
                    return new DropdownMenuItem(
                      value: value,
                      child: new Text(value),
                    );
                  }).toList(),