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.
Why am I getting "No FSelect<$T> found in context..." assertion errors?
This is likely because Dart could not infer FSelect's type parameter. Try specifying the type parameter for
FSelect, FSelectSection, and FSelectItem (e.g., FSelect<MyType>).
See:
- https://forui.dev/docs/form/select for working examples.
- FSelectController for customizing the behavior of a select.
- FSelectStyle for customizing the appearance of a select.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FSelect
- Mixed-in types
Constructors
-
FSelect({required Map<
String, T> items, FSelectControl<T> ? control, FPopoverControl popoverControl = const .managed(), FSelectStyle style(FSelectStyle style)?, bool autofocus = false, FocusNode? focusNode, FFieldBuilder<FSelectStyle> builder = _fieldBuilder, FFieldIconBuilder<FSelectStyle> ? prefixBuilder, FFieldIconBuilder<FSelectStyle> ? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, FormFieldSetter<T> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode = .onUnfocus, String? forceErrorText, FormFieldValidator<T> validator = _defaultValidator, Widget errorBuilder(BuildContext context, String message) = FFormFieldProperties.defaultErrorBuilder, String? hint, TextAlign textAlign = .start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands = false, MouseCursor mouseCursor = .defer, bool canRequestFocus = true, bool clearable = false, AlignmentGeometry contentAnchor = AlignmentDirectional.topStart, AlignmentGeometry fieldAnchor = AlignmentDirectional.bottomStart, FPortalConstraints contentConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing contentSpacing = const .spacing(4), FPortalOverflow contentOverflow = .flip, Offset contentOffset = .zero, FPopoverHideRegion contentHideRegion = .excludeChild, Object? contentGroupId, bool autoHide = true, Widget contentEmptyBuilder(BuildContext context, FSelectStyle style) = defaultContentEmptyBuilder, ScrollController? contentScrollController, @Deprecated('Usage of scroll handles seem to be low while its maintenance burden far outweighs its benefits. Please open an issue at https://github.com/duobaseio/forui/issues if you use it and think otherwise.') bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), FItemDivider contentDivider = .none, Key? key}) -
Creates a FSelect from the given
items.factory -
FSelect.rich({required String format(T value), required List<
FSelectItemMixin> children, FSelectControl<T> ? control, FPopoverControl popoverControl, FSelectStyle style(FSelectStyle style)?, bool autofocus, FocusNode? focusNode, FFieldBuilder<FSelectStyle> builder, FFieldIconBuilder<FSelectStyle> ? prefixBuilder, FFieldIconBuilder<FSelectStyle> ? suffixBuilder, Widget? label, Widget? description, bool enabled, FormFieldSetter<T> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<T> validator, Widget errorBuilder(BuildContext context, String message), String? hint, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, AlignmentGeometry contentAnchor, AlignmentGeometry fieldAnchor, FPortalConstraints contentConstraints, FPortalSpacing contentSpacing, FPortalOverflow contentOverflow, Offset contentOffset, FPopoverHideRegion contentHideRegion, Object? contentGroupId, bool autoHide, Widget contentEmptyBuilder(BuildContext context, FSelectStyle style), ScrollController? contentScrollController, @Deprecated('Usage of scroll handles seem to be low while its maintenance burden far outweighs its benefits. Please open an issue at https://github.com/duobaseio/forui/issues if you use it and think otherwise.') bool contentScrollHandles, ScrollPhysics contentPhysics, FItemDivider contentDivider, Key? key}) -
Creates a select with the given
children.constfactory -
FSelect.search({required Map<
String, T> items, FutureOr<Iterable< filter(String query)?, FSelectSearchFieldProperties searchFieldProperties = const FSelectSearchFieldProperties(), Widget contentLoadingBuilder(BuildContext context, FSelectSearchStyle style) = FSelect.defaultContentLoadingBuilder, Widget contentErrorBuilder(BuildContext context, Object? error, StackTrace stackTrace)?, FSelectControl<T> >T> ? control, FPopoverControl popoverControl = const .managed(), FSelectStyle style(FSelectStyle style)?, bool autofocus = false, FocusNode? focusNode, FFieldBuilder<FSelectStyle> builder = _fieldBuilder, FFieldIconBuilder<FSelectStyle> ? prefixBuilder, FFieldIconBuilder<FSelectStyle> ? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, FormFieldSetter<T> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode = .onUnfocus, String? forceErrorText, FormFieldValidator<T> validator = _defaultValidator, Widget errorBuilder(BuildContext context, String message) = FFormFieldProperties.defaultErrorBuilder, String? hint, TextAlign textAlign = .start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands = false, MouseCursor mouseCursor = .defer, bool canRequestFocus = true, bool clearable = false, AlignmentGeometry contentAnchor = AlignmentDirectional.topStart, AlignmentGeometry fieldAnchor = AlignmentDirectional.bottomStart, FPortalConstraints contentConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing contentSpacing = const .spacing(4), FPortalOverflow contentOverflow = .flip, Offset contentOffset = .zero, FPopoverHideRegion contentHideRegion = .excludeChild, Object? contentGroupId, bool autoHide = true, Widget contentEmptyBuilder(BuildContext context, FSelectStyle style) = defaultContentEmptyBuilder, ScrollController? contentScrollController, @Deprecated('Usage of scroll handles seem to be low while its maintenance burden far outweighs its benefits. Please open an issue at https://github.com/duobaseio/forui/issues if you use it and think otherwise.') bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), FItemDivider contentDivider = .none, Key? key}) -
Creates a searchable select with dynamic content based on the given
itemsand search input.factory -
FSelect.searchBuilder({required String format(T value), required FutureOr<
Iterable< filter(String query), required FSelectSearchContentBuilder<T> >T> contentBuilder, FSelectSearchFieldProperties searchFieldProperties, Widget contentLoadingBuilder(BuildContext context, FSelectSearchStyle style), Widget contentErrorBuilder(BuildContext context, Object? error, StackTrace stackTrace)?, FSelectControl<T> ? control, FPopoverControl popoverControl, FSelectStyle style(FSelectStyle style)?, bool autofocus, FocusNode? focusNode, FFieldBuilder<FSelectStyle> builder, FFieldIconBuilder<FSelectStyle> ? prefixBuilder, FFieldIconBuilder<FSelectStyle> ? suffixBuilder, Widget? label, Widget? description, bool enabled, FormFieldSetter<T> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<T> validator, Widget errorBuilder(BuildContext context, String message), String? hint, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, AlignmentGeometry contentAnchor, AlignmentGeometry fieldAnchor, FPortalConstraints contentConstraints, FPortalSpacing contentSpacing, FPortalOverflow contentOverflow, Offset contentOffset, FPopoverHideRegion contentHideRegion, Object? contentGroupId, bool autoHide, Widget contentEmptyBuilder(BuildContext context, FSelectStyle style), ScrollController? contentScrollController, @Deprecated('Usage of scroll handles seem to be low while its maintenance burden far outweighs its benefits. Please open an issue at https://github.com/duobaseio/forui/issues if you use it and think otherwise.') bool contentScrollHandles, ScrollPhysics contentPhysics, FItemDivider contentDivider, Key? key}) -
Creates a searchable select with dynamic content based on search input.
constfactory
Properties
- 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
→ FFieldBuilder<
FSelectStyle> -
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
- contentAnchor → AlignmentGeometry
-
The alignment point on the popover. Defaults to AlignmentDirectional.topStart.
final
- contentConstraints → FPortalConstraints
-
The constraints to apply to the popover. Defaults to
const FAutoWidthPortalConstraints(maxHeight: 300).final - contentDivider → FItemDivider
-
The divider used to separate the content items. Defaults to FItemDivider.none.
final
- contentEmptyBuilder → Widget Function(BuildContext context, FSelectStyle style)
-
The builder that is called when the select's content is empty. Defaults to defaultContentEmptyBuilder.
final
- contentGroupId → Object?
-
An optional group ID that groups TapRegions together so that they operate as one region. If a tap occurs outside
of all group members, then group members that are shown will be hidden.
final
- contentHideRegion → FPopoverHideRegion
-
The region that can be tapped to hide the popover.
final
- contentOffset → Offset
-
Additional translation to apply to the popover's position.
final
- contentOverflow → FPortalOverflow
-
The callback used to shift a popover when it overflows out of the viewport.
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
- contentSpacing → FPortalSpacing
-
The spacing between the popover and child anchors.
final
-
control
→ FSelectControl<
T> ? -
The control that manages the select's state.
final
- description → Widget?
-
The description.
final
- enabled → bool
-
Whether the form is able to receive user input.
final
- errorBuilder → Widget Function(BuildContext context, String message)
-
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 AlignmentDirectional.bottomStart.
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 value)
-
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
- hint → String?
-
The hint that is displayed when the select is empty. Defaults to the current locale's
FLocalizations.selectHint.
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 MouseCursor.defer.
final
- onReset → VoidCallback?
-
An optional method to call when the form field is reset via FormFieldState.reset.
final
-
onSaved
→ FormFieldSetter<
T> ? -
An optional method to call with the final value when the form is saved via FormState.save.
final
- popoverControl → FPopoverControl
-
Defines how the select's popover is controlled.
final
-
prefixBuilder
→ FFieldIconBuilder<
FSelectStyle> ? -
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
- style → FSelectStyle Function(FSelectStyle style)?
-
The style.
final
-
suffixBuilder
→ FFieldIconBuilder<
FSelectStyle> ? -
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
-
defaultContentEmptyBuilder(
BuildContext context, FSelectStyle style) → Widget - The default content empty builder that shows a localized message when there are no results.
-
defaultContentLoadingBuilder(
BuildContext _, FSelectSearchStyle style) → Widget - The default content loading builder that shows a spinner when an asynchronous search is pending.
-
defaultIconBuilder(
BuildContext _, FSelectStyle style, Set< WidgetState> _) → Widget - The default suffix builder that shows a upward and downward facing chevron icon.