In Flutter, a Wrap widget attempts to place the child adjacent to the previous child in the main axis, and if there is not enough space to fit the child, it creates a new run adjacent to the existing children in the cross axis.
So, for example, if 3 children fit in a horizontal run, and we have 4 children, it will have 2 runs: The first with 3 children, and the second with 1 child.
Instead, after defining that number of runs, I would like it to "balance" the placement of these children, so that it occupies the same amount of runs, but the least amount of width.
In the above example, that would mean having 2 children in the first run, and 2 children in the second. But, of course, this should work to any number of children of any width.
How can I do that?
As suggested by Rémi, I've recreated the Wrap
widget with custom rules: The WrapSuper
widget in https://pub.dev/packages/assorted_layout_widgets solves this.
It doesn't exactly guarantees the least amount of width, but instead the minimum raggedness, which is more precisely what I wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With