TreeDropdown<T extends Object> class

A dropdown widget that displays items in a tree structure with connecting lines.

This widget combines the functionality of a dropdown select with tree view visualization, allowing users to select items from a hierarchical structure.

Example:

final dropdownController = TreeDropdownController<Node>();

TreeDropdown<Node>(
  controller: dropdownController,
  treeController: treeController,
  itemBuilder: (context, entry) => Text(entry.node.title),
  guide: IndentGuide.connectingLines(indent: 40, roundCorners: true),
)
Inheritance

Constructors

TreeDropdown({Key? key, TreeDropdownController<T>? controller, required TreeController<T> treeController, required Widget itemBuilder(BuildContext context, TreeEntry<T> entry), T? selectedValue, void onChanged(T? value)?, Widget? placeholder, String? label, bool isRequired = false, String? validator(T?)?, bool enabled = true, IndentGuide? guide, double maxHeight = 400, bool fillWidth = false, bool showClearButton = false, VoidCallback? onClear, BoxConstraints? constraints, Color? borderColor, Color? focusedBorderColor, Color? errorBorderColor, double? borderWidth, BorderRadius? borderRadius, bool searchEnabled = false, String searchPlaceholder = 'Search...', String emptyMessage = 'No items found', Future<void> onSearch(String query)?, bool isLoading = false, Future<void> onLoadMore()?, bool hasMore = false, bool isItemEnabled(T item)?, bool allowMultipleSelection = false, List<T>? selectedValues, void onMultipleChanged(List<T> values)?, String? displayLabelSelectedItems})
const

Properties

allowMultipleSelection bool
Whether to allow multiple selection with checkboxes
final
borderColor Color?
Border color (normal state)
final
borderRadius BorderRadius?
Border radius
final
borderWidth double?
Border width
final
constraints BoxConstraints?
Box constraints for the dropdown
final
controller TreeDropdownController<T>?
Optional controller for managing dropdown state If not provided, an internal controller will be created
final
displayLabelSelectedItems String?
final
emptyMessage String
Message to show when no items found
final
enabled bool
Whether the dropdown is enabled
final
errorBorderColor Color?
Border color (error state)
final
fillWidth bool
Whether to fill the full width
final
focusedBorderColor Color?
Border color (focused state)
final
guide IndentGuide?
Visual guide for tree indentation (connectingLines, scopingLines, or none)
final
hashCode int
The hash code for this object.
no setterinherited
hasMore bool
Whether there are more items to load
final
isItemEnabled bool Function(T item)?
Callback to determine if an item can be selected Returns true if the item is enabled, false if disabled Disabled items will appear grayed out and cannot be selected
final
isLoading bool
Whether data is currently loading
final
isRequired bool
Whether the field is required
final
itemBuilder Widget Function(BuildContext context, TreeEntry<T> entry)
Builder for creating widgets from tree entries
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
Label text above the dropdown
final
maxHeight double
Maximum height of the dropdown popup
final
onChanged → void Function(T? value)?
Callback when selection changes
final
onClear VoidCallback?
Callback when clear button is pressed
final
onLoadMore Future<void> Function()?
Callback when user scrolls near bottom (for infinite scroll)
final
onMultipleChanged → void Function(List<T> values)?
Callback when multiple selection changes
final
onSearch Future<void> Function(String query)?
Callback when search query changes (for async data fetching)
final
placeholder Widget?
Placeholder text when no value is selected
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchEnabled bool
Whether to enable search
final
searchPlaceholder String
Search placeholder text
final
selectedValue → T?
Currently selected value
final
selectedValues List<T>?
Currently selected values (multi-selection mode)
final
showClearButton bool
Whether to show a clear button
final
treeController TreeController<T>
Controller managing the tree state
final
validator String? Function(T?)?
Validation function
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TreeDropdown<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