UniversalDropdown<T> class
Constructors
-
UniversalDropdown({Key? key, List<T>? items, List<T>? selectedItems, required ValueChanged<List<T>> onChanged, Future<List<T>> fetchItems(int page, int pageSize, String query)?, bool multiSelect = false, bool closeOnSelectWhenSingle = true, bool searchable = false, bool paginate = false, int pageSize = 20, Color dragPanelBgColor = Colors.white, String placeholder = 'Select…', DropdownMode mode = DropdownMode.overlay, Alignment dropdownAlignment = Alignment.topLeft, Offset dropdownOffset = Offset.zero, BoxDecoration? dropdownDecoration, double dropdownMaxHeight = 320, EdgeInsetsGeometry dropdownPadding = const EdgeInsets.symmetric(vertical: 8, horizontal: 8), VoidCallback? handleScroll, required Widget itemBuilder(BuildContext context, T item, bool isSelected, int index), Widget selectedDisplayBuilder(BuildContext context, List<T> selected, VoidCallback open, VoidCallback clear)?, Widget checkboxBuilder(BuildContext context, bool isSelected)?, CheckboxPosition checkboxPosition = CheckboxPosition.leading, Widget chipBuilder(BuildContext context, T item, VoidCallback onRemove)?, ChipPlacement chipPlacement = ChipPlacement.belowField, double chipSpacing = 8, WrapAlignment chipWrapAlignment = WrapAlignment.start, Widget searchBarBuilder(BuildContext context, TextEditingController controller, VoidCallback clear, ValueChanged<String> onChanged)?, Widget loaderBuilder(BuildContext context)?, Widget emptyStateBuilder(BuildContext context)?, Widget separatorBuilder(BuildContext context, int index)?, EdgeInsetsGeometry listPadding = const EdgeInsets.symmetric(vertical: 4), Duration animationDuration = const Duration(milliseconds: 180), Curve animationCurve = Curves.easeOutCubic})
-
Properties
-
animationCurve
→ Curve
-
final
-
animationDuration
→ Duration
-
Animation tuning (overlay open/close).
final
-
checkboxBuilder
→ Widget Function(BuildContext context, bool isSelected)?
-
Build the checkbox/toggle indicator used for each item.
If null, a Material Checkbox/Radio is used depending on multiSelect.
final
-
checkboxPosition
→ CheckboxPosition
-
Where to place the checkbox relative to the item row.
final
-
chipBuilder
→ Widget Function(BuildContext context, T item, VoidCallback onRemove)?
-
Chips for multi-select summary (when not providing your own selected display).
final
-
chipPlacement
→ ChipPlacement
-
Where to render the chips (if using default selected display).
final
-
chipSpacing
→ double
-
Spacing + alignment for default chips area.
final
-
chipWrapAlignment
→ WrapAlignment
-
final
-
closeOnSelectWhenSingle
→ bool
-
final
-
dragPanelBgColor
→ Color
-
BottomSheet Draggable Panel background Color
final
-
dropdownAlignment
→ Alignment
-
final
-
dropdownDecoration
→ BoxDecoration?
-
final
-
dropdownMaxHeight
→ double
-
final
-
dropdownOffset
→ Offset
-
final
-
dropdownPadding
→ EdgeInsetsGeometry
-
final
-
emptyStateBuilder
→ Widget Function(BuildContext context)?
-
Empty-state when there are no items to show.
final
-
fetchItems
→ Future<List<T>> Function(int page, int pageSize, String query)?
-
Async data source for pagination / server search.
Signature: (page, pageSize, searchQuery) => Future<List
final
-
final
-
handleScroll
↔ VoidCallback?
-
Handle Pagination Scroll
getter/setter pair
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
Optional header/footer widgets inside dropdown panel.
final
-
itemBuilder
→ Widget Function(BuildContext context, T item, bool isSelected, int index)
-
===== Builders: give you total control =====
Item row in the list (you decide every pixel).
final
-
items
→ List<T>?
-
Static items (optional if using fetchItems).
final
-
key
→ Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
listPadding
→ EdgeInsetsGeometry
-
List padding inside dropdown.
final
-
loaderBuilder
→ Widget Function(BuildContext context)?
-
Loader for pagination.
final
-
mode
→ DropdownMode
-
final
-
multiSelect
→ bool
-
===== Behavior =====
final
-
onChanged
→ ValueChanged<List<T>>
-
Callback when selection changes.
final
-
pageSize
→ int
-
final
-
paginate
→ bool
-
final
-
placeholder
→ String
-
===== Visuals: Field & Dropdown =====
final
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
scrollCtrl
→ ScrollController
-
ScrollController
final
-
searchable
→ bool
-
final
-
searchBarBuilder
→ Widget Function(BuildContext context, TextEditingController controller, VoidCallback clear, ValueChanged<String> onChanged)?
-
Search bar (fully custom). Given controller + clear helper + onChanged.
final
-
selectedDisplayBuilder
→ Widget Function(BuildContext context, List<T> selected, VoidCallback open, VoidCallback clear)?
-
How the closed field looks. Tap should open the dropdown; we also
pass a helper
open to do that and clear to clear selection.
final
-
selectedItems
→ List<T>?
-
Pre-selected items (mutated internally via copies; original list is not modified).
final
-
separatorBuilder
→ Widget Function(BuildContext context, int index)?
-
Optional separator between items.
final