Skip to content

Support Auto Layout When Columns is not Divisible by ColumnSpan #105

@PvtPuddles

Description

@PvtPuddles

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),
      ],
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions