FMultiSelect<T> class
abstract
A multi-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 FMultiSelect<$T> found in context..." assertion errors?
This is likely because Dart could not infer FMultiSelect's type parameter. Try specifying the type parameter for
FMultiSelect
, FSelectSection
, and FSelectItem
(e.g., FMultiSelect<MyType>
).
See:
- https://forui.dev/docs/form/multi-select for working examples.
- FMultiSelectController for customizing the behavior of a select.
- FMultiSelectStyle for customizing the appearance of a select.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FMultiSelect
Constructors
-
FMultiSelect.new({required Map<
String, T> items, FMultiSelectController<T> ? controller, FMultiSelectStyle style(FMultiSelectStyle)?, bool autofocus = false, FocusNode? focusNode, FFieldIconBuilder<FMultiSelectStyle> ? prefixBuilder, FFieldIconBuilder<FMultiSelectStyle> ? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, ValueChanged<Set< ? onChange, void onSaved(Set<T> >T> )?, AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus, String? forceErrorText, String? validator(Set<T> ) = _defaultValidator, Widget errorBuilder(BuildContext, String) = FFormFieldProperties.defaultErrorBuilder, Widget? hint, bool keepHint = true, int sort(T, T)?, Widget tagBuilder(BuildContext, FMultiSelectController<T> , FMultiSelectStyle, T, Widget)?, TextAlign textAlign = TextAlign.start, TextDirection? textDirection, bool clearable = false, AlignmentGeometry anchor = AlignmentDirectional.topStart, AlignmentGeometry fieldAnchor = AlignmentDirectional.bottomStart, FPortalConstraints popoverConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing spacing = const FPortalSpacing(4), Offset shift(Size, FPortalChildBox, FPortalBox) = FPortalShift.flip, Offset offset = Offset.zero, FPopoverHideRegion hideRegion = FPopoverHideRegion.excludeChild, Widget contentEmptyBuilder(BuildContext, FMultiSelectStyle) = FMultiSelect.defaultContentEmptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), FItemDivider contentDivider = FItemDivider.none, int min = 0, int? max, Set<T> ? initialValue, Key? key}) -
Creates a FMultiSelect from the given
items
.factory -
FMultiSelect.rich({required Widget format(T), required List<
FSelectItemMixin> children, FMultiSelectController<T> ? controller, FMultiSelectStyle style(FMultiSelectStyle)?, bool autofocus, FocusNode? focusNode, FFieldIconBuilder<FMultiSelectStyle> ? prefixBuilder, FFieldIconBuilder<FMultiSelectStyle> ? suffixBuilder, Widget? label, Widget? description, bool enabled, ValueChanged<Set< ? onChange, void onSaved(Set<T> >T> )?, AutovalidateMode autovalidateMode, String? forceErrorText, String? validator(Set<T> ), Widget errorBuilder(BuildContext, String), Widget? hint, bool keepHint, int sort(T, T)?, FMultiSelectTagBuilder<T> ? tagBuilder, TextAlign textAlign, TextDirection? textDirection, bool clearable, AlignmentGeometry anchor, AlignmentGeometry fieldAnchor, FPortalConstraints popoverConstraints, FPortalSpacing spacing, Offset shift(Size, FPortalChildBox, FPortalBox), Offset offset, FPopoverHideRegion hideRegion, Widget contentEmptyBuilder(BuildContext, FMultiSelectStyle), ScrollController? contentScrollController, bool contentScrollHandles, ScrollPhysics contentPhysics, FItemDivider contentDivider, int min, int? max, Set<T> ? initialValue, Key? key}) -
Creates a FMultiSelect with the given
children
.factory -
FMultiSelect.search(Map<
String, T> items, {FutureOr<Iterable< filter(String)?, FSelectSearchFieldProperties searchFieldProperties = const FSelectSearchFieldProperties(), Widget contentLoadingBuilder(BuildContext, FSelectSearchStyle) = FMultiSelect.defaultContentLoadingBuilder, Widget contentErrorBuilder(BuildContext, Object?, StackTrace)?, FMultiSelectController<T> >T> ? controller, FMultiSelectStyle style(FMultiSelectStyle)?, bool autofocus = false, FocusNode? focusNode, FFieldIconBuilder<FMultiSelectStyle> ? prefixBuilder, FFieldIconBuilder<FMultiSelectStyle> ? suffixBuilder = defaultIconBuilder, Widget? label, Widget? description, bool enabled = true, ValueChanged<Set< ? onChange, void onSaved(Set<T> >T> )?, AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus, String? forceErrorText, String? validator(Set<T> ) = _defaultValidator, Widget errorBuilder(BuildContext, String) = FFormFieldProperties.defaultErrorBuilder, Widget? hint, bool keepHint = true, int sort(T, T)?, FMultiSelectTagBuilder<T> ? tagBuilder, TextAlign textAlign = TextAlign.start, TextDirection? textDirection, bool clearable = false, AlignmentGeometry anchor = AlignmentDirectional.topStart, AlignmentGeometry fieldAnchor = AlignmentDirectional.bottomStart, FPortalConstraints popoverConstraints = const FAutoWidthPortalConstraints(maxHeight: 300), FPortalSpacing spacing = const FPortalSpacing(4), Offset shift(Size, FPortalChildBox, FPortalBox) = FPortalShift.flip, Offset offset = Offset.zero, FPopoverHideRegion hideRegion = FPopoverHideRegion.excludeChild, Widget contentEmptyBuilder(BuildContext, FMultiSelectStyle) = defaultContentEmptyBuilder, ScrollController? contentScrollController, bool contentScrollHandles = false, ScrollPhysics contentPhysics = const ClampingScrollPhysics(), FItemDivider contentDivider = FItemDivider.none, int min = 0, int? max, Set<T> ? initialValue, Key? key}) -
Creates a searchable select with dynamic content based on the given
items
and search input.factory -
FMultiSelect.searchBuilder({required Widget format(T), required FutureOr<
Iterable< filter(String), required FSelectSearchContentBuilder<T> >T> contentBuilder, FSelectSearchFieldProperties searchFieldProperties, Widget contentLoadingBuilder(BuildContext, FSelectSearchStyle), Widget contentErrorBuilder(BuildContext, Object?, StackTrace)?, FMultiSelectController<T> ? controller, FMultiSelectStyle style(FMultiSelectStyle)?, bool autofocus, FocusNode? focusNode, FFieldIconBuilder<FMultiSelectStyle> ? prefixBuilder, FFieldIconBuilder<FMultiSelectStyle> ? suffixBuilder, Widget? label, Widget? description, bool enabled, ValueChanged<Set< ? onChange, void onSaved(Set<T> >T> )?, AutovalidateMode autovalidateMode, String? forceErrorText, String? validator(Set<T> ), Widget errorBuilder(BuildContext, String), Widget? hint, bool keepHint, int sort(T, T)?, FMultiSelectTagBuilder<T> ? tagBuilder, TextAlign textAlign, TextDirection? textDirection, bool clearable, AlignmentGeometry anchor, AlignmentGeometry fieldAnchor, FPortalConstraints popoverConstraints, FPortalSpacing spacing, Offset shift(Size, FPortalChildBox, FPortalBox), Offset offset, FPopoverHideRegion hideRegion, Widget contentEmptyBuilder(BuildContext, FMultiSelectStyle), ScrollController? contentScrollController, bool contentScrollHandles, ScrollPhysics contentPhysics, FItemDivider contentDivider, int min, int? max, Set<T> ? initialValue, Key? key}) -
Creates a searchable select with dynamic content based on search input.
factory
Properties
- anchor → AlignmentGeometry
-
The alignment point on the popover. Defaults to AlignmentDirectional.topStart.
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
- autovalidateMode → AutovalidateMode
-
Used to enable/disable this form field's auto validation and update its error text.
final
- clearable → bool
-
True if a clear button should be shown. Defaults to false.
final
- contentDivider → FItemDivider
-
The divider used to separate the content items. Defaults to FItemDivider.none.
final
- contentEmptyBuilder → Widget Function(BuildContext, FMultiSelectStyle)
-
The builder that is called when the select is empty. Defaults to FSelect.defaultContentEmptyBuilder.
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
→ FMultiSelectController<
T> ? -
The controller.
final
- description → Widget?
-
The description.
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
- 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 → Widget Function(T)
-
The function formats the value for display in the select's field.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hideRegion → FPopoverHideRegion
-
The region that can be tapped to hide the popover.
final
- hint → Widget?
-
The hint.
final
-
initialValue
→ Set<
T> -
The initial value.
final
- keepHint → bool
-
Whether to keep the hint visible when there are selected items. Defaults to true.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → Widget?
-
The label.
final
- max → int?
-
The maximum number of items that can be selected. Defaults to null.
final
- min → int
-
The minimum number of items that needs to be selected. Defaults to 0.
final
- offset → Offset
-
The offset to adjust the popover by. Defaults to Offset.zero.
final
-
onChange
→ ValueChanged<
Set< ?T> > -
Handler called when the selected value changes.
final
-
onSaved
→ void Function(Set<
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
→ FFieldIconBuilder<
FMultiSelectStyle> ? -
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
- sort → int Function(T, T)?
-
The function used to sort the selected items. Defaults to the order in which they were selected.
final
- spacing → FPortalSpacing
-
The spacing between the child's anchor and popover's anchor. Defaults to
FPortalSpacing(4)
.final - style → FMultiSelectStyle Function(FMultiSelectStyle)?
-
The style.
final
-
suffixBuilder
→ FFieldIconBuilder<
FMultiSelectStyle> ? -
Builds a widget at the end of the select that can be pressed to toggle the popover. Defaults to defaultIconBuilder.
final
-
tagBuilder
→ FMultiSelectTagBuilder<
T> -
The function used to build the tags for selected items.
final
- textAlign → TextAlign
-
The alignment of the text within the select. Defaults to TextAlign.start.
final
- textDirection → TextDirection?
-
The text direction of the select.
final
-
validator
→ String? Function(Set<
T> ) -
An optional method that validates an input. Returns an error string to
display if the input is invalid, or null otherwise.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's 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, FMultiSelectStyle style) → Widget - The default content empty builder that shows a localized message when there are no results.
-
defaultContentLoadingBuilder(
BuildContext _, FSelectSearchStyle style) → Widget - The default loading builder that shows a spinner when an asynchronous search is pending.
-
defaultIconBuilder(
BuildContext _, FMultiSelectStyle style, Set< WidgetState> states) → Widget - The default suffix builder that shows a upward and downward facing chevron icon.
-
defaultTagBuilder<
T> (BuildContext _, FMultiSelectController< T> controller, FMultiSelectStyle style, T value, Widget label) → Widget - The default tag builder that builds a FMultiSelectTag with the given value.