GridLayoutDelegate.autoFill constructor

GridLayoutDelegate.autoFill({
  1. required List<LayoutId> autoFillItems,
  2. required int columnCount,
  3. EdgeInsetsGeometry layoutPadding = const EdgeInsets.all(2.0),
  4. Size itemPadding = const Size(2.0, 2.0),
  5. GridLayoutAlignment lastRowAlignment = GridLayoutAlignment.start,
})

Auto fill mode:

In this mode, all items will auto fill the available space, and the layout will have the SAME height as the screen. Make sure to wrap CustomMultiChildLayout with a Container with a specific height.

|I| or |I I| |I I| or |I I I| |I I I| |I I |

example:

final items = List.generate(5, (index) { return LayoutId( id: index, child: Container(color: Colors.red100 * (index % 8 + 1)), ); });

return SingleChildScrollView( child: SizedBox( // you must wrap CustomMultiChildLayout with Container with height height: MediaQuery.of(context).size.height, child: CustomMultiChildLayout( delegate: GridLayoutDelegate.autoFill( normalItems: items, columnCount: 3, lastRowAlignment: GridLayoutAlignment.center, ), children: items, ), ), );

Implementation

GridLayoutDelegate.autoFill({
  required this.autoFillItems,
  required this.columnCount,
  this.layoutPadding = const EdgeInsets.all(2.0),
  this.itemPadding = const Size(2.0, 2.0),
  this.lastRowAlignment = GridLayoutAlignment.start,
}) : assert(columnCount > 0) {
  if (autoFillItems.length < columnCount) {
    columnCount = autoFillItems.length;
  }
}