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

Constructors

TSelect({Key? key, String? label, String? tag, String? helperText, String? placeholder, bool isRequired = false, bool disabled = false, bool autoFocus = 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 = 7, String? search, int? searchDelay, TLoadListener<T>? onLoad, TListController<T, K>? controller, VoidCallback? onShow, VoidCallback? onHide, bool filterable = true, ItemTextAccessor<T>? itemSubText, ItemTextAccessor<T>? itemImageUrl, ItemChildrenAccessor<T>? itemChildren, TListCardTheme? cardTheme, ItemValueAccessor<T, V>? itemValue, ItemTextAccessor<T>? itemText, ItemKeyAccessor<T, K>? itemKey, bool? readOnly})
Creates a dropdown select field.
const

Properties

alignment TPopupAlignment
Preferred alignment of the popup.
no setterinherited
autoFocus bool
Whether the field should auto-focus.
final
cardTheme TListCardTheme?
Custom theme for list item cards.
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
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
listTheme TListTheme?
Custom theme for the dropdown list.
final
offset double
Offset from the target widget.
no setterinherited
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
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
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

Methods

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
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
validateValue(V? value) List<String>
Validates the given value against the rules.
inherited

Operators

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