easyGridOf<T> function

Widget easyGridOf<T>({
  1. required List<T> items,
  2. T? value,
  3. List<T>? values,
  4. ValueChanged<T?>? onChanged,
  5. ValueChanged<List<T>>? onChangedMany,
  6. bool multiSelect = false,
  7. String itemLabel(
    1. T
    )?,
  8. int crossAxisCount = 2,
  9. double mainAxisSpacing = 12,
  10. double crossAxisSpacing = 12,
  11. double childAspectRatio = 1,
  12. String? label,
})

Creates a grid view.

items - The list of items to display. value - The currently selected value. values - The currently selected values (multi selection). onChanged - Callback when an item is selected. onChangedMany - Callback when items are selected (multi selection). multiSelect - Whether to allow multiple selections. itemLabel - Function to convert an item to a string label. crossAxisCount - Number of columns in the grid. mainAxisSpacing - Spacing along the main axis. crossAxisSpacing - Spacing along the cross axis. childAspectRatio - Aspect ratio of grid items. label - Optional label for the grid.

Implementation

Widget easyGridOf<T>({
  required List<T> items,
  T? value,
  List<T>? values,
  ValueChanged<T?>? onChanged,
  ValueChanged<List<T>>? onChangedMany,
  bool multiSelect = false,
  String Function(T)? itemLabel,
  int crossAxisCount = 2,
  double mainAxisSpacing = 12,
  double crossAxisSpacing = 12,
  double childAspectRatio = 1,
  String? label,
}) {
  return _easyLabelWrapper(
    label: label,
    child: EasyGrid<T>(
      items: items,
      value: value,
      selectedValues: values ?? const [],
      onChanged: onChanged,
      onChangedMultiple: onChangedMany,
      multiSelect: multiSelect,
      itemBuilder: (context, item, selected) =>
          _defaultItemBuilder(context, item, selected, itemLabel),
      crossAxisCount: crossAxisCount,
      mainAxisSpacing: mainAxisSpacing,
      crossAxisSpacing: crossAxisSpacing,
      childAspectRatio: childAspectRatio,
    ),
  );
}