GridLayoutDelegate.sized constructor

GridLayoutDelegate.sized({
  1. required List<GridLayoutSizedItem> sizedItems,
  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,
})

Sized mode:

In this mode, all items will be laid out according to the specified width and height, and may exceed the screen height.

I I I I I I |I I I| |I I I| |I I I| I I I I I I

example:

var columnCount = 3; var screenSize = MediaQuery.of(context).size;

final items = List.generate(20, (index) { var width = screenSize.width / columnCount - 2.0; var height = 120.0; return GridLayoutSizedItem( width: width, height: height, id: index, child: Container( width: width, height: height, color: Colors.red100 * (index % 8 + 1), ), ); });

return SingleChildScrollView( child: CustomMultiChildLayout( delegate: GridLayoutDelegate.sized( sizedItems: items, columnCount: columnCount, lastRowAlignment: GridLayoutAlignment.center, ), children: items, ), );

Implementation

GridLayoutDelegate.sized({
  required this.sizedItems,
  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);