DropdownButton in ListView/Column causing a rendering error

I'm trying to get a DropdownButton to display inside a ListView. Although the ListView code is in another file, this button is a direct child of that ListView.

Trying to add the widget directly did not work, giving this error:

I/flutter (22767): RenderIndexedStack object was given an infinite size during layout.
I/flutter (22767): This probably means that it is a render object that tries to be as big as possible, but it was put
I/flutter (22767): inside another render object that allows its children to pick their own size.

So I attempted to put it inside a simple Column/Flexible combination with nothing else added, as that's what I saw recommended from Google.

widgets.add(Column(children: [Flexible(child: subdropdown)],));

This gave me this error:

I/flutter (22767): RenderFlex children have non-zero flex but incoming height constraints are unbounded.
I/flutter (22767): When a column is in a parent that does not provide a finite height constraint, for example if it is
I/flutter (22767): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
I/flutter (22767): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
I/flutter (22767): space in the vertical direction.
I/flutter (22767): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter (22767): cannot simultaneously expand to fit its parent.
I/flutter (22767): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
I/flutter (22767): children (using Flexible rather than Expanded). This will allow the flexible children to size
I/flutter (22767): themselves to less than the infinite remaining space they would otherwise be forced to take, and
I/flutter (22767): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
I/flutter (22767): constraints provided by the parent.

Then I tried following these instructions, and setting the mainAxisSize and the FlexFit just brought back the original error.

widgets.add(Column(mainAxisSize: MainAxisSize.min, children: [Flexible(child: subdropdown, fit: FlexFit.loose)],));

I looked at this thread, but that one has the dropdown rendering something, it's just rendering incorrectly. The errors I'm getting interrupts the rendering, so it doesn't show anything at all.

- - Source
comments powered by Disqus