MultiDropdown<T extends Object>.future constructor
const
MultiDropdown<T extends Object>.future ({
- required FutureRequest<
T> ? future, - FieldDecoration fieldDecoration = const FieldDecoration(),
- DropdownDecoration dropdownDecoration = const DropdownDecoration(),
- SearchFieldDecoration searchDecoration = const SearchFieldDecoration(),
- DropdownItemDecoration dropdownItemDecoration = const DropdownItemDecoration(),
- AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
- bool singleSelect = false,
- Widget? itemSeparator,
- MultiSelectController<
T> ? controller, - String? validator(
- List<
DropdownItem< ? selectedOptionsT> >
- List<
- DropdownItemBuilder<
T> ? itemBuilder, - bool enabled = true,
- ChipDecoration chipDecoration = const ChipDecoration(),
- bool searchEnabled = false,
- int maxSelections = 0,
- SelectedItemBuilder<
T> ? selectedItemBuilder, - FocusNode? focusNode,
- OnSelectionChanged<
T> ? onSelectionChange, - OnSearchChanged? onSearchChange,
- bool closeOnBackButton = false,
- Widget loadingBuilder(
- BuildContext context
- double? fieldMaxHeight,
- 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);