getRowListWidget method

List<Widget> getRowListWidget(
  1. int rowItemCount
)

Returns the list of item widgets arranged in rows.

Implementation

List<Widget> getRowListWidget(int rowItemCount) {
  List<Widget> result = [];

  var itemCount = (itemList.length - 1) ~/ rowItemCount;
  for (var i = 0; i <= itemCount; i++) {
    Row rowData = Row(
      children: List.generate(
        rowItemCount,
        (index) {
          int curruentIndex = i * rowItemCount + index;
          return Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (index != 0) ...[
                SizedBox(width: spacing),
              ],
              if (curruentIndex < itemList.length) ...[
                SizedBox(
                  width: itemWidth,
                  height: itemHeight,
                  child: itemBuilder(
                    itemList[i * rowItemCount + index],
                  ),
                ),
              ] else ...[
                SizedBox(
                  width: itemWidth,
                  height: itemHeight,
                ),
              ],
            ],
          );
        },
      ),
    );
    result.add(rowData);
  }

  return result;
}