MultiSelectDropdownPlus<C extends StateStreamableSource<S> , S> class
A multi-select dropdown that integrates with any BLoC/Cubit.
Type Parameters
C— your Cubit/Bloc type, e.g.WorkerCubitS— the state type emitted byC, e.g.WorkerState
Key Features
- Select / deselect multiple items with animated circular checkboxes
- "Select All" / "Clear All" header action
- Chip display with overflow "+N more" badge
- Real-time search via onSearch
- Offline caching with client-side fallback filtering
- Controlled mode via selectedItems
- Full visual customisation via dropdownTheme or preset themeStyle
- Custom item & chip builders
Basic Usage
MultiSelectDropdownPlus<WorkerCubit, WorkerState>(
cubit: workerCubit,
hintText: 'Select workers…',
onSearch: workerCubit.search,
onStateChange: (state, updateList, updateLoading) {
if (state is WorkersLoaded) {
updateList(state.workers
.map((w) => DropdownItem(value: w, label: w.name))
.toList());
updateLoading(false);
} else if (state is WorkersLoading) {
updateLoading(true);
}
},
onSelectionChanged: (items) =>
setState(() => _selected = items.map((e) => e.value).toList()),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MultiSelectDropdownPlus
Constructors
-
MultiSelectDropdownPlus({required C cubit, required void onSearch(String query), required void onStateChange(S state, void updateList(List<
DropdownItem> ), void updateLoading(bool)), required String hintText, Key? key, List<DropdownItem> selectedItems = const [], void onSelectionChanged(List<DropdownItem> items)?, String? searchHint, String? noResultsText, String? loadingText, bool needInitialFetch = false, int maxDisplayChips = 2, DropdownPlusTheme? dropdownTheme, DropdownPlusThemeStyle? themeStyle, Widget itemBuilder(DropdownItem item, bool isSelected)?, Widget selectedItemBuilder(List<DropdownItem> selected)?, double? buttonHeight, double? buttonWidth, Future<bool> checkInternetConnection()?}) -
const
Properties
-
Fixed height of the trigger button.
final
-
Fixed width of the trigger button.
final
-
checkInternetConnection
→ Future<
bool> Function()? -
Optional internet check — enables offline caching when provided.
final
- cubit → C
-
The BLoC/Cubit instance that drives this dropdown.
final
- dropdownTheme → DropdownPlusTheme?
-
Visual customisation. When null, themeStyle is used if set.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String
-
Placeholder text shown when nothing is selected.
final
- itemBuilder → Widget Function(DropdownItem item, bool isSelected)?
-
Override item row rendering.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingText → String?
-
Message shown while loading.
final
- maxDisplayChips → int
-
Maximum chips shown before "+N more" overflow. Default:
2.final - needInitialFetch → bool
-
If
true, onSearch is called on widget mount.final - noResultsText → String?
-
Message shown when search returns no results.
final
- onSearch → void Function(String query)
-
Called whenever the user types in the search box.
final
-
onSelectionChanged
→ void Function(List<
DropdownItem> items)? -
Called when the user changes the selection.
final
-
onStateChange
→ void Function(S state, void updateList(List<
DropdownItem> ), void updateLoading(bool)) -
Maps incoming BLoC/Cubit states to list updates.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchHint → String?
-
Hint text for the search input. Defaults to
'Search…'.final -
selectedItemBuilder
→ Widget Function(List<
DropdownItem> selected)? -
Override the chips display inside the trigger button.
final
-
selectedItems
→ List<
DropdownItem> -
Pre-selected items (controlled mode).
final
- themeStyle → DropdownPlusThemeStyle?
-
Preset theme style. Ignored when dropdownTheme is non-null.
Use for out-of-the-box looks: DropdownPlusThemeStyle.minimal,
DropdownPlusThemeStyle.dark, etc.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MultiSelectDropdownPlus< C, S> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited