wrapWidgets static method

List<Widget> wrapWidgets(
  1. List<Widget> widgets,
  2. int rowSize
)

Wrap widgets in rows based on the specified rowSize.

Implementation

static List<Widget> wrapWidgets(List<Widget> widgets, int rowSize) {
  final wrappedList = <Widget>[];
  for (var i = 0; i < widgets.length; i += rowSize) {
    final rowChildren = widgets.sublist(
        i, i + rowSize > widgets.length ? widgets.length : i + rowSize);
    wrappedList.add(Row(children: rowChildren));
  }
  return wrappedList;
}