flutter_layout_grid
flutter_layout_grid copied to clipboard
Support Auto Layout When Columns is not Divisible by ColumnSpan
In the following code, the second Placeholder is assigned to the first row, even though the row is not wide enough to hold it. This causes a FlutterError ("GridPlacement.columnEnd cannot exceed column count"). There is enough space for all of the Placeholders if they are laid out vertically.
LayoutGrid(
columnSizes: repeat(3, [50.px]),
rowSizes: repeat(5, [50.px]),
autoPlacement: AutoPlacement.rowSparse,
children: [
for (int i = 0; i < 4; i++)
Placeholder().withGridPlacement(columnSpan: 2),
],
);
Note that this code works fine (columns increased to 4), since the second Placeholder takes up exactly as much space as is left in the row, so the next placeholder can layout properly.
LayoutGrid(
columnSizes: repeat(4, [50.px]),
rowSizes: repeat(5, [50.px]),
autoPlacement: AutoPlacement.rowSparse,
children: [
for (int i = 0; i < 4; i++)
Placeholder().withGridPlacement(columnSpan: 2),
],
);