easySearchableGridOf<T> function
- required List<
T> items, - required String itemLabel(
- T
- required EasyItemBuilder<
T> itemBuilder, - T? value,
- List<
T> ? values, - ValueChanged<
T?> ? onChanged, - ValueChanged<
List< ? onChangedMany,T> > - bool multiSelect = false,
- String hintText = 'Search...',
- Widget? emptyState,
- int crossAxisCount = 2,
- double mainAxisSpacing = 12,
- double crossAxisSpacing = 12,
- double childAspectRatio = 1,
- String? label,
Creates a searchable grid.
items - The list of items to display.
itemLabel - Function to convert an item to a string label.
itemBuilder - Function to build grid items.
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.
hintText - Hint text for the search field.
emptyState - Widget to display when no items match.
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 easySearchableGridOf<T>({
required List<T> items,
required String Function(T) itemLabel,
required EasyItemBuilder<T> itemBuilder,
T? value,
List<T>? values,
ValueChanged<T?>? onChanged,
ValueChanged<List<T>>? onChangedMany,
bool multiSelect = false,
String hintText = 'Search...',
Widget? emptyState,
int crossAxisCount = 2,
double mainAxisSpacing = 12,
double crossAxisSpacing = 12,
double childAspectRatio = 1,
String? label,
}) {
return _easyLabelWrapper(
label: label,
child: EasySearchableGrid<T>(
items: items,
labelBuilder: itemLabel,
itemBuilder: itemBuilder,
value: value,
values: values ?? const [],
onChanged: onChanged,
onChangedMany: onChangedMany,
multiSelect: multiSelect,
hintText: hintText,
emptyState: emptyState,
crossAxisCount: crossAxisCount,
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio,
),
);
}