GridLayoutDelegate.autoFill constructor
GridLayoutDelegate.autoFill({
- required List<
LayoutId> autoFillItems, - required int columnCount,
- EdgeInsetsGeometry layoutPadding = const EdgeInsets.all(2.0),
- Size itemPadding = const Size(2.0, 2.0),
- 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;
}
}