easySearchableGridOf<T> function

Widget easySearchableGridOf<T>({
  1. required List<T> items,
  2. required String itemLabel(
    1. T
    ),
  3. required EasyItemBuilder<T> itemBuilder,
  4. T? value,
  5. List<T>? values,
  6. ValueChanged<T?>? onChanged,
  7. ValueChanged<List<T>>? onChangedMany,
  8. bool multiSelect = false,
  9. String hintText = 'Search...',
  10. Widget? emptyState,
  11. int crossAxisCount = 2,
  12. double mainAxisSpacing = 12,
  13. double crossAxisSpacing = 12,
  14. double childAspectRatio = 1,
  15. 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,
    ),
  );
}