easyGridOf<T> function
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,
),
);
}