MultiDropdown<T extends Object>.future constructor

const MultiDropdown<T extends Object>.future({
  1. required FutureRequest<T>? future,
  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. Widget loadingBuilder(
    1. BuildContext context
    )?,
  22. double? fieldMaxHeight,
  23. Key? key,
})

Creates a multiselect dropdown widget with future request.

The future is the future request for the dropdown items. You can use this to fetch the dropdown items asynchronously.

A loading indicator will be displayed while the future is in progress at the suffix icon. The dropdown will be disabled until the future is completed.

Example:

MultiDropdown<User>.future(
 future: () async {
  final response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/users'));
 final data = jsonDecode(response.body) as List;
return data.map((e) => DropdownItem(
 label: e['name'] as String,
value: e['id'] as int,
)).toList();
},
);

Implementation

const MultiDropdown.future({
  required this.future,
  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.loadingBuilder,
  this.fieldMaxHeight,
  Key? key,
})  : items = const [],
      search = null,
      searchDebounceDuration = null,
      super(key: key);