I read
Renderflex children have non-zero flex…, which seemed to do a pretty good job of explaining the layout requirements in Flutter.
What it doesn't do is complete the theory with how I tell what widgets or settings give me the constraints to satisfy the layout algorithm.
When I search for advice about how to fix "renderflex children have non-zero…" and suchlike errors, I find a whole grab-bag of narrow solutions ("wrap the thing in an Expand", "wrap the thing in a Flex", "add a height constraint", "set shrinkwrap: true"…).
Is there some canonical list of what things provide constraints of what sort, or some way to easily glean this from the documentation, or something? Any advice about interpreting the errors that arise?
Right now, I'm trying to make a box I can drop draggable buttons into where it will queue them up (a dice-rolling app where you can make sets of dice you can roll together). I have, as the build in my DiceRow class:
List<DieWidget> dice = [];
@override
Widget build(BuildContext context) {
return Row(
children: [
IconButton(
icon: Icon(Icons.refresh),
tooltip: 'Reroll',
onPressed: null,
),
ListView(
children: dice,
scrollDirection: Axis.horizontal,
)
]
);
and a DiceRack class's build:
List<DiceRow> rows = [DiceRow()];
@override
Widget build(BuildContext context) {
return Column( // This will be scrollable once I get the other one working
children: rows,
);
}
I've tried all of the grab-bag of things I mentioned at the top, scattered in various places. Everything I try seems like it might fit the theory explained in the first link above. But I can't get this thing to display without giving me some form of unbounded error or the like.