FSelect<T> class abstract

A select displays a list of options for the user to pick from.

It is a FormField and therefore can be used in a Form widget.

See:

Inheritance
Mixed-in types

Constructors

FSelect.new({required String format(T), required List<FSelectItemMixin> children, FSelectController<T>? controller, FSelectStyle? style, bool autofocus, FocusNode? focusNode, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)> builder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder, Widget? label, Widget? description, bool enabled, ValueChanged<T?>? onChange, FormFieldSetter<T>? onSaved, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<T> validator, Widget errorBuilder(BuildContext, String), String? hint, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, AlignmentGeometry anchor, AlignmentGeometry fieldAnchor, FPortalConstraints popoverConstraints, FPortalSpacing spacing, Offset shift(Size, FPortalChildBox, FPortalBox), Offset offset, FHidePopoverRegion hideOnTapOutside, bool autoHide, ValueWidgetBuilder<FSelectStyle> emptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles, ScrollPhysics contentPhysics, T? initialValue, Key? key})
Creates a select with a list of selectable items.
const
factory
FSelect.fromMap(Map<String, T> items, {FSelectController<T>? controller, FSelectStyle? style, bool autofocus = false, FocusNode? focusNode, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)> builder = _fieldBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, ValueChanged<T?>? onChange, FormFieldSetter<T>? onSaved, AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus, String? forceErrorText, FormFieldValidator<T> validator = _defaultValidator, Widget errorBuilder(BuildContext, String) = FFormFieldProperties.defaultErrorBuilder, String? hint, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands = false, MouseCursor mouseCursor = SystemMouseCursors.click, bool canRequestFocus = true, bool clearable = false, AlignmentGeometry anchor = Alignment.topLeft, AlignmentGeometry fieldAnchor = Alignment.bottomLeft, FPortalConstraints popoverConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing spacing = const FPortalSpacing(4), Offset shift(Size, FPortalChildBox, FPortalBox) = FPortalShift.flip, Offset offset = Offset.zero, FHidePopoverRegion hideOnTapOutside = FHidePopoverRegion.excludeTarget, bool autoHide = true, ValueWidgetBuilder<FSelectStyle> emptyBuilder = defaultEmptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), T? initialValue, Key? key})
Creates a FSelect from the given items.
factory
FSelect.search({required String format(T), required FSelectSearchFilter<T> filter, required FSelectSearchContentBuilder<T> contentBuilder, FSelectSearchFieldProperties searchFieldProperties, ValueWidgetBuilder<FSelectSearchStyle> searchLoadingBuilder, Widget searchErrorBuilder(BuildContext, Object?, StackTrace)?, FSelectController<T>? controller, FSelectStyle? style, bool autofocus, FocusNode? focusNode, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)> builder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder, Widget? label, Widget? description, bool enabled, ValueChanged<T?>? onChange, FormFieldSetter<T>? onSaved, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<T> validator, Widget errorBuilder(BuildContext, String), String? hint, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, AlignmentGeometry anchor, AlignmentGeometry fieldAnchor, FPortalConstraints popoverConstraints, FPortalSpacing spacing, Offset shift(Size, FPortalChildBox, FPortalBox), Offset offset, FHidePopoverRegion hideOnTapOutside, bool autoHide, ValueWidgetBuilder<FSelectStyle> emptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles, ScrollPhysics contentPhysics, T? initialValue, Key? key})
Creates a searchable select with dynamic content based on search input.
const
factory
FSelect.searchFromMap(Map<String, T> items, {FSelectSearchFilter<T>? filter, FSelectSearchFieldProperties searchFieldProperties = const FSelectSearchFieldProperties(), ValueWidgetBuilder<FSelectSearchStyle> searchLoadingBuilder = FSelect.defaultSearchLoadingBuilder, Widget searchErrorBuilder(BuildContext, Object?, StackTrace)?, FSelectController<T>? controller, FSelectStyle? style, bool autofocus = false, FocusNode? focusNode, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)> builder = _fieldBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, ValueChanged<T?>? onChange, FormFieldSetter<T>? onSaved, AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus, String? forceErrorText, FormFieldValidator<T> validator = _defaultValidator, Widget errorBuilder(BuildContext, String) = FFormFieldProperties.defaultErrorBuilder, String? hint, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands = false, MouseCursor mouseCursor = SystemMouseCursors.click, bool canRequestFocus = true, bool clearable = false, AlignmentGeometry anchor = Alignment.topLeft, AlignmentGeometry fieldAnchor = Alignment.bottomLeft, FPortalConstraints popoverConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing spacing = const FPortalSpacing(4), Offset shift(Size, FPortalChildBox, FPortalBox) = FPortalShift.flip, Offset offset = Offset.zero, FHidePopoverRegion hideOnTapOutside = FHidePopoverRegion.excludeTarget, bool autoHide = true, ValueWidgetBuilder<FSelectStyle> emptyBuilder = defaultEmptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), T? initialValue, Key? key})
Creates a searchable select with dynamic content based on the given items and search input.
factory

Properties

anchor AlignmentGeometry
The alignment point on the popover. Defaults to Alignment.topLeft.
final
autofocus bool
True if this widget will be selected as the initial focus when no other node in its scope is currently focused.
final
autoHide bool
True if the select should be automatically hidden after an item is selected. Defaults to false.
final
autovalidateMode AutovalidateMode
Used to enable/disable this form field's auto validation and update its error text.
final
builder ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>
The builder used to decorate the select. It should use the given child.
final
canRequestFocus bool
Whether the field can request focus. Defaults to true.
final
clearable bool
True if a clear button should be shown. Defaults to false.
final
contentPhysics ScrollPhysics
The content's scroll physics. Defaults to ClampingScrollPhysics.
final
contentScrollController ScrollController?
The content's scroll controller.
final
contentScrollHandles bool
True if the content should show scroll handles instead of a scrollbar. Defaults to false.
final
controller FSelectController<T>?
The controller.
final
description Widget?
The description.
final
emptyBuilder ValueWidgetBuilder<FSelectStyle>
The builder that is called when the select is empty. Defaults to defaultEmptyBuilder.
final
enabled bool
Whether the form is able to receive user input.
final
errorBuilder Widget Function(BuildContext, String)
The builder for errors displayed below the description. Defaults to displaying the error message.
final
expands bool
True if the select should expand to fill the available space. Defaults to false.
final
fieldAnchor AlignmentGeometry
The alignment point on the select's field. Defaults to Alignment.bottomLeft.
final
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
forceErrorText String?
An optional property that forces the FormFieldState into an error state by directly setting the FormFieldState.errorText property without running the validator function.
final
format String Function(T)
The function that formats the selected items into a string. The items are sorted in order of selection.
final
hashCode int
The hash code for this object.
no setterinherited
hideOnTapOutside FHidePopoverRegion
The region that can be tapped to hide the popover.
final
hint String?
The hint that is displayed when the select is empty. Defaults to the current locale's FLocalizations.selectHint.
final
initialValue → T?
The initial value.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label Widget?
The label.
final
mouseCursor MouseCursor
The mouse cursor to use when the field is hovered over. Defaults to SystemMouseCursors.click.
final
offset Offset
The offset to adjust the popover by. Defaults to Offset.zero.
final
onChange ValueChanged<T?>?
Handler called when the selected value changes.
final
onSaved FormFieldSetter<T>?
An optional method to call with the final value when the form is saved via FormState.save.
final
popoverConstraints FPortalConstraints
The constraints to apply to the popover. Defaults to const FAutoWidthPortalConstraints(maxHeight: 300).
final
prefixBuilder ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>?
Builds a widget at the start of the select that can be pressed to toggle the popover. Defaults to no icon.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shift Offset Function(Size, FPortalChildBox, FPortalBox)
The shifting strategy used to shift a popover when it overflows out of the viewport. Defaults to FPortalShift.flip.
final
spacing FPortalSpacing
The spacing between the child's anchor and popover's anchor. Defaults to FPortalSpacing(4).
final
style FSelectStyle?
The style.
final
suffixBuilder ValueWidgetBuilder<(FSelectStyle, FTextFieldStyle, Set<WidgetState>)>?
Builds a widget at the end of the select that can be pressed to toggle the popover. Defaults to defaultIconBuilder.
final
textAlign TextAlign
The alignment of the text within the select. Defaults to TextAlign.start.
final
textAlignVertical TextAlignVertical?
The vertical alignment of the text and can be useful when used with a prefix or suffix.
final
textDirection TextDirection?
The text direction of the select.
final
validator FormFieldValidator<T>
An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
final

Methods

createElement() StatefulElement
Creates a StatefulElement 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.
inherited
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.
override
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

Static Methods

defaultEmptyBuilder(BuildContext context, FSelectStyle style, Widget? _) Widget
The default empty builder that shows a localized message when there are no results.
defaultIconBuilder(BuildContext _, (FSelectStyle, FTextFieldStyle, Set<WidgetState>) styles, Widget? _) Widget
The default suffix builder that shows a upward and downward facing chevron icon.
defaultSearchLoadingBuilder(BuildContext _, FSelectSearchStyle style, Widget? _) Widget
The default loading builder that shows a spinner when an asynchronous search is pending.