CustomDropdown<T> class
A fully customizable dropdown widget with support for search, pagination (API or local), multi-selection, and extensive styling options.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CustomDropdown
Constructors
-
CustomDropdown({Key? key, List<
T> ? items, FutureRequest<T> ? futureRequest, T? selectedItem, List<T> ? selectedItems, bool enableMultiSelection = false, bool enabled = true, String itemLabel(T)?, ValueChanged<T?> ? onChanged, ValueChanged<List< ? onListChanged, String hintText = "Select", String searchHintText = "Search...", double dropdownHeight = 300, BoxDecoration? headerDecoration, TextStyle? headerTextStyle, BoxDecoration? dropdownDecoration, BoxDecoration? selectedItemDecoration, TextStyle? listItemStyle, TextStyle? selectedListItemStyle, EdgeInsetsGeometry? headerPadding, EdgeInsetsGeometry? listItemPadding, Widget headerBuilder(BuildContext context, T? selectedItem, List<T> >T> selectedItems)?, Widget listItemBuilder(BuildContext context, T item, bool isSelected, VoidCallback onTap)?, Widget searchFieldBuilder(BuildContext context, TextEditingController controller, ValueChanged<String> onSearch)?, Widget? noResultFoundWidget, Widget? loadingWidget, Widget? errorWidget, int itemsPerPage = 10, Duration searchDebounce = const Duration(milliseconds: 500), String doneButtonText = "Done", TextStyle? doneButtonStyle}) -
const
Properties
- doneButtonStyle → TextStyle?
-
Style for done button in multi-selection.
final
- doneButtonText → String
-
Text to verify / close multi-select dropdown.
final
- dropdownDecoration → BoxDecoration?
-
Decoration for the dropdown overlay (the list).
final
- dropdownHeight → double
-
Height of the dropdown overlay.
final
- enabled → bool
-
Enable/Disable the dropdown.
final
- enableMultiSelection → bool
-
Enable multi-selection mode.
final
- errorWidget → Widget?
-
Widget to display when an error occurs.
final
-
futureRequest
→ FutureRequest<
T> ? -
A function to fetch items asynchronously (for API data).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headerBuilder
→ Widget Function(BuildContext context, T? selectedItem, List<
T> selectedItems)? -
Custom builder for the header (the button).
final
- headerDecoration → BoxDecoration?
-
Decoration for the dropdown header (the button).
final
- headerPadding → EdgeInsetsGeometry?
-
Padding for the header.
final
- headerTextStyle → TextStyle?
-
TextStyle for the dropdown header text.
final
- hintText → String
-
Hint text to display when no item is selected.
final
- itemLabel → String Function(T)?
-
A function that returns the string representation of an item.
Used in the default header and list item widgets.
final
-
items
→ List<
T> ? -
The list of items to display (for local data).
If futureRequest is provided, this is ignored (or used as initial data).
final
- itemsPerPage → int
-
Number of items to fetch per page (for API pagination).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- listItemBuilder → Widget Function(BuildContext context, T item, bool isSelected, VoidCallback onTap)?
-
Custom builder for list items.
final
- listItemPadding → EdgeInsetsGeometry?
-
Padding for the list items.
final
- listItemStyle → TextStyle?
-
TextStyle for the items in the list.
final
- loadingWidget → Widget?
-
Widget to display when loading (initial or pagination).
final
- noResultFoundWidget → Widget?
-
Widget to display when no items are found.
final
-
onChanged
→ ValueChanged<
T?> ? -
Callback when an item is selected (Single Selection Mode).
final
-
onListChanged
→ ValueChanged<
List< ?T> > -
Callback when items are selected (Multi Selection Mode).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchDebounce → Duration
-
Debounce duration for search.
final
-
searchFieldBuilder
→ Widget Function(BuildContext context, TextEditingController controller, ValueChanged<
String> onSearch)? -
Custom builder for the search field.
final
- searchHintText → String
-
Hint text for the search field.
final
- selectedItem → T?
-
The currently selected item (Single Selection Mode).
final
- selectedItemDecoration → BoxDecoration?
-
Decoration for the selected item in the list.
final
-
selectedItems
→ List<
T> ? -
The currently selected items (Multi Selection Mode).
final
- selectedListItemStyle → TextStyle?
-
TextStyle for the selected item in the list.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CustomDropdown< T> > -
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