SelectFormField<T> class

A form field representing single-option selection from a list of choices.

Users navigate the list of choices using the Up and Down arrow keys.

Example

SelectFormField<int>(
  label: 'Select priority',
  initialValue: 2,
  options: const [
    SelectOption('High', 1),
    SelectOption('Normal', 2),
    SelectOption('Low', 3),
  ],
)
Inheritance

Constructors

SelectFormField({required String label, String description = '', required List<SelectOption<T>> options, T? initialValue, String? validator(T?)?, bool focused = false})
Creates a SelectFormField with the given options.

Properties

description → String
Optional secondary description text for helper information.
finalinherited
errorText ↔ String?
The validation error text if validation fails; otherwise, null.
getter/setter pairinherited
focused ↔ bool
Whether this field currently has input focus.
getter/setter pairinherited
hasError → bool
Returns whether this field currently contains a validation error.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
initialValue → T?
The initial value of the field when created or reset.
finalinherited
key → Key?
The optional key for this widget.
finalinherited
label → String
The title label displayed for this field.
finalinherited
options → List<SelectOption<T>>
The list of available options for selection.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
touched ↔ bool
Whether this field has been focused at least once.
getter/setter pairinherited
validator → String? Function(T?)?
A validation function called by FormState.validate. Returns an error message string if invalid, or null if valid.
finalinherited
value ↔ T?
The current value of the form field.
getter/setter pairinherited

Methods

createElement() → Element
Creates an Element to manage this widget's location in the tree.
inherited
createState() → State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
getIntrinsicHeight(int width) → int
Computes the intrinsic height of this widget under the given width constraint.
inherited
getIntrinsicWidth(int height) → int
Computes the intrinsic width of this widget under the given height constraint.
inherited
getPreferredHeight() → int
Calculates preferred layout height needed to render this field cleanly.
override
handleKeyEvent(KeyEvent event) → bool
Handles user key inputs to update the internal value.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
validate() → bool
Runs the validator callback against the current field value. Updates errorText and returns whether the field is valid.
inherited

Operators

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