Flutter RenderIndexedStack object was given an infinite size during layout
I was able to reproduce your issue, I am not sure why are you building the layout this way. Your are feeding your DropDownButton
as the child
property for InputDecorator
, which is fine. However, it is throwing this error because DropDownMenuItem
is overflowing your InputDecorator
. In other words, you are not only containing the DopDownButton
within your InputDecorator
, but also your items
are trying to be contained in the same space as well. So, Flutter is confused on how to position the list of items
inside the space provided by the InputDecorator
.
I am really confused what kind of layout you are trying to build, why do you need a Form
and an InputDecorator
for?
Maybe provide a little context to your design choices so that we can help better.
I have created a simpler layout with Row
and TextField
widgets, it might be of help.
class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState();}class _MyAppState extends State<MyApp> { String _mySelection; String _text = "Choose"; List<Map> _myJson = [ {"id": "ID 1310012", "name": "Newcommer"}, {"id": "ID 0000TEMP", "name": "Temp"}]; Widget _children() { TextEditingController _controller = new TextEditingController(text: _text); return new Expanded(child: new ListView( padding: const EdgeInsets.symmetric(horizontal: 16.0), children: <Widget>[ new Container ( child: new Row( children: <Widget>[ new Expanded( child: new TextField( controller: _controller, ), ), new DropdownButton( isDense: true, value: _mySelection, items: _myJson.map((Map map) { return new DropdownMenuItem<String>( value: map["id"], child: new Text( map["name"], ), ); }).toList(), onChanged: (String newValue) { setState(() { _mySelection = newValue; _text = newValue; }); }) ],),), new RaisedButton( child: new Text('Start'), onPressed: null), ] )); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text("Test")), body: new Column( mainAxisSize: MainAxisSize.max, children: <Widget>[ _children(), ], ), ); }}