MultiDropdown<T extends Object> constructor

const MultiDropdown<T extends Object>({
  1. required List<DropdownItem<T>> items,
  2. FieldDecoration fieldDecoration = const FieldDecoration(),
  3. DropdownDecoration dropdownDecoration = const DropdownDecoration(),
  4. SearchFieldDecoration searchDecoration = const SearchFieldDecoration(),
  5. DropdownItemDecoration dropdownItemDecoration = const DropdownItemDecoration(),
  6. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  7. bool singleSelect = false,
  8. Widget? itemSeparator,
  9. MultiSelectController<T>? controller,
  10. String? validator(
    1. List<DropdownItem<T>>? selectedOptions
    )?,
  11. DropdownItemBuilder<T>? itemBuilder,
  12. bool enabled = true,
  13. ChipDecoration chipDecoration = const ChipDecoration(),
  14. bool searchEnabled = false,
  15. int maxSelections = 0,
  16. SelectedItemBuilder<T>? selectedItemBuilder,
  17. FocusNode? focusNode,
  18. OnSelectionChanged<T>? onSelectionChange,
  19. OnSearchChanged? onSearchChange,
  20. bool closeOnBackButton = false,
  21. double? fieldMaxHeight,
  22. Key? key,
})

Creates a multiselect dropdown widget.

The items are the list of dropdown items. It is required.

The fieldDecoration is the decoration of the field. The default value is FieldDecoration(). It can be used to customize the field decoration.

The dropdownDecoration is the decoration of the dropdown. The default value is DropdownDecoration(). It can be used to customize the dropdown decoration.

The searchDecoration is the decoration of the search field. The default value is SearchFieldDecoration(). It can be used to customize the search field decoration. If searchEnabled is true, then the search field will be displayed.

The dropdownItemDecoration is the decoration of the dropdown items. The default value is DropdownItemDecoration(). It can be used to customize the dropdown item decoration.

The autovalidateMode is the autovalidate mode for the dropdown. The default value is AutovalidateMode.disabled.

The singleSelect is the selection type of the dropdown. The default value is false. If true, only one item can be selected at a time.

The itemSeparator is the separator between the dropdown items.

The controller is the controller for the dropdown. It can be used to control the dropdown programmatically.

The validator is the validator for the dropdown. It can be used to validate the dropdown.

The itemBuilder is the builder for the dropdown items. If not provided, the default ListTile will be used.

The enabled is whether the dropdown is enabled. The default value is true.

The chipDecoration is the configuration for the chips. The default value is ChipDecoration(). It can be used to customize the chip decoration. The chips are displayed when an item is selected.

The searchEnabled is whether the search field is enabled. The default value is false.

The maxSelections is the maximum number of selections allowed. The default value is 0.

The selectedItemBuilder is the builder for the selected items. If not provided, the default Chip will be used.

The focusNode is the focus node for the dropdown.

The onSelectionChange is the callback when the item is changed.

The closeOnBackButton is whether to close the dropdown when the back button is pressed. The default value is false. Note: This option requires the app to have a router, such as MaterialApp.router, in order to work properly.

Implementation

const MultiDropdown({
  required this.items,
  this.fieldDecoration = const FieldDecoration(),
  this.dropdownDecoration = const DropdownDecoration(),
  this.searchDecoration = const SearchFieldDecoration(),
  this.dropdownItemDecoration = const DropdownItemDecoration(),
  this.autovalidateMode = AutovalidateMode.disabled,
  this.singleSelect = false,
  this.itemSeparator,
  this.controller,
  this.validator,
  this.itemBuilder,
  this.enabled = true,
  this.chipDecoration = const ChipDecoration(),
  this.searchEnabled = false,
  this.maxSelections = 0,
  this.selectedItemBuilder,
  this.focusNode,
  this.onSelectionChange,
  this.onSearchChange,
  this.closeOnBackButton = false,
  this.fieldMaxHeight,
  Key? key,
})  : future = null,
      search = null,
      searchDebounceDuration = null,
      loadingBuilder = null,
      super(key: key);