代码之家  ›  专栏  ›  技术社区  ›  MistyD Harish Kumar Kailas

将小部件放置在列中会使RenderIndexedStack对象在布局期间具有无限大小

  •  1
  • MistyD Harish Kumar Kailas  · 技术社区  · 7 年前

    我将以下内容放在这样的专栏中

       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 回复  |  直到 7 年前
        1
  •  0
  •   User    7 年前

    他们的问题可能是因为下拉按钮中的项目。 我试过在物品中使用它,效果很好:

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