TSelect<T, V, K> class

A dropdown select field with search, pagination, and hierarchical support.

TSelect provides a powerful select component with:

  • Single selection from a list of items
  • Optional search/filtering
  • Pagination for large datasets
  • Server-side data loading
  • Hierarchical/nested items
  • Custom item rendering
  • Validation support

Basic Usage

TSelect<String, String, String>(
  label: 'Country',
  items: ['USA', 'Canada', 'Mexico'],
  placeholder: 'Select a country',
  onValueChanged: (value) => print('Selected: $value'),
)

With Custom Objects

class User {
  final int id;
  final String name;
  User(this.id, this.name);
}

TSelect<User, int, int>(
  label: 'User',
  items: users,
  itemText: (user) => user.name,
  itemValue: (user) => user.id,
  onValueChanged: (userId) => print('Selected user ID: $userId'),
)

With Server-Side Loading

TSelect<Product, int, int>(
  label: 'Product',
  itemsPerPage: 10,
  itemText: (product) => product.name,
  itemValue: (product) => product.id,
  onLoad: (page, search) async {
    final response = await api.getProducts(page, search);
    return (response.items, response.hasMore);
  },
)

Type parameters:

  • T: The type of items in the list
  • V: The type of the selected value
  • K: The type of the item key (for tracking selection)

See also:

Inheritance
Mixed-in types
Available extensions

Constructors

TSelect({Key? key, String? label, String? tag, String? helperText, String? placeholder, String? info, bool isRequired = false, bool disabled = false, bool autoFocus = false, bool clearable = false, TTextFieldTheme? theme, VoidCallback? onTap, FocusNode? focusNode, TextEditingController? textController, V? value, ValueNotifier<V?>? valueNotifier, ValueChanged<V?>? onValueChanged, List<String? Function(V?)>? rules, Duration? validationDebounce, TListTheme? listTheme, List<T>? items, int? itemsPerPage, String? search, int? searchDelay, TLoadListener<T>? onLoad, TListController<T, K>? controller, TControllerReadyListener<T, K>? onControllerReady, VoidCallback? onShow, VoidCallback? onHide, TPopupMode? popupMode, bool filterable = true, ItemTextAccessor<T>? itemSubText, ItemTextAccessor<T>? itemImageUrl, ItemChildrenAccessor<T>? itemChildren, TListCardTheme? cardTheme, ItemValueAccessor<T, V>? itemValue, bool lazy = false, bool loadOnSearchOnly = false, int? visibleItemsCount, ItemTextAccessor<T>? itemText, ItemKeyAccessor<T, K>? itemKey, bool? readOnly})
Creates a dropdown select field.
const

Properties

autoFocus → bool
Whether the field should auto-focus.
final
cardTheme → TListCardTheme?
Custom theme for list item cards.
final
clearable → bool
Whether to show a clear button when an item is selected.
final
controller → TListController<T, K>?
Controller for managing list state.
final
disabled → bool
Whether the field is disabled.
final
filterable → bool
Whether the select field is filterable/searchable.
final
focusNode → FocusNode?
Custom focus node.
final
hashCode → int
The hash code for this object.
no setterinherited
helperText → String?
Helper text displayed below the field.
final
info → String?
The info text (optional).
final
isRequired → bool
Whether this field is required.
final
itemChildren → ItemChildrenAccessor<T>?
Function to extract child items for hierarchical display.
final
itemImageUrl → ItemTextAccessor<T>?
Function to extract image URL from an item.
final
itemKey → ItemKeyAccessor<T, K>?
Function to extract a unique key from an item.
final
items → List<T>?
The list of items to display.
final
itemsPerPage → int?
Number of items to display per page.
final
itemSubText → ItemTextAccessor<T>?
Function to extract subtitle text from an item.
final
itemText → ItemTextAccessor<T>
Function to extract display text from an item.
final
itemValue → ItemValueAccessor<T, V>?
Function to extract the value to store when an item is selected.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → String?
The label text displayed above the field.
final
lazy → bool
Whether to load items lazily when the dropdown is first opened.
final
listTheme → TListTheme?
Custom theme for the dropdown list.
final
loadOnSearchOnly → bool
Whether to only load data when a search query is present.
final
offset → double
Offset from the target widget.
no setterinherited
onControllerReady → TControllerReadyListener<T, K>?
Callback fired when the list controller is initialized and ready.
final
onHide → VoidCallback?
Callback fired when the dropdown is hidden.
final
onLoad → TLoadListener<T>?
Callback for loading items from a server.
final
onShow → VoidCallback?
Callback fired when the dropdown is shown.
final
onTap → VoidCallback?
Callback fired when the field is tapped.
final
onValueChanged → ValueChanged<V?>?
Callback fired when the selected value changes.
final
placeholder → String?
Placeholder text shown when no item is selected.
final
popupAlignment → TPopupAlignment
Preferred alignment of the popup.
no setterinherited
popupMode → TPopupMode?
Preferred display mode of the popup.
final
readOnly → bool
Whether the field is read-only.
final
rules → List<String? Function(V?)>?
Validation rules for the selected value.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
Initial search query.
final
searchDelay → int?
Debounce delay for search in milliseconds.
final
showCloseButton → bool
Whether to show a close button in the popup.
no setterinherited
tag → String?
An optional tag displayed next to the label.
final
textController → TextEditingController?
Custom text editing controller.
final
theme → TTextFieldTheme?
Custom theme for the text field.
final
validationDebounce → Duration?
Debounce duration for validation.
final
value → V?
The currently selected value.
final
valueNotifier → ValueNotifier<V?>?
A ValueNotifier for two-way binding.
final
visibleItemsCount → int?
The number of items to show as visible in the dropdown before scrolling.
final

Methods

box({double minW = 0.0, double minH = 0.0, double maxW = double.infinity, double maxH = double.infinity}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a ConstrainedBox to apply layout constraints.
center({bool when = true}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Center widget.
createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<TSelect<T, V, K>>
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
expanded({int flex = 1}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in an Expanded widget.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
padding([double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0]) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Padding with flexible edge control.
paddingSymmetric({double h = 0.0, double v = 0.0}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Padding with symmetric horizontal and vertical spacing.
size({double? w, double? h}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a SizedBox to apply fixed width and/or height.
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
validateValue(V? value) → List<String>
Validates the given value against the rules.
inherited
visible(bool visible, {bool maintainState = false}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Visibility widget.
when(bool condition) → Widget

Available on Widget, provided by the WidgetX extension

Returns this widget if condition is true, otherwise returns SizedBox.shrink(). Usage: Text('Hello').when(isVisible)

Operators

operator ==(Object other) → bool
The equality operator.
inherited