FMultiSelect<T> constructor
FMultiSelect<T> ({
- required Map<
String, T> items, - FMultiSelectController<
T> ? controller, - FMultiSelectStyle style()?,
- bool autofocus = false,
- FocusNode? focusNode,
- FFieldIconBuilder<
FMultiSelectStyle> ? prefixBuilder, - FFieldIconBuilder<
FMultiSelectStyle> ? suffixBuilder = defaultIconBuilder, - Widget? label,
- Widget? description,
- bool enabled = true,
- ValueChanged<
Set< ? onChange,T> > - void onSaved(
- Set<
T>
- Set<
- AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus,
- String? forceErrorText,
- String? validator(
- Set<
T>
- Set<
- Widget errorBuilder() = FFormFieldProperties.defaultErrorBuilder,
- Widget? hint,
- bool keepHint = true,
- int sort(
- T,
- T
- Widget 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() = FPortalShift.flip,
- Offset offset = Offset.zero,
- FPopoverHideRegion hideRegion = FPopoverHideRegion.excludeChild,
- Widget contentEmptyBuilder() = 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
.
For more control over the appearance of items, use FMultiSelect.rich.
Contract
Each key in items
must map to a unique value. Having multiple keys map to the same value will result in
undefined behavior.
Implementation
factory FMultiSelect({
required Map<String, T> items,
FMultiSelectController<T>? controller,
FMultiSelectStyle Function(FMultiSelectStyle)? style,
bool autofocus = false,
FocusNode? focusNode,
FFieldIconBuilder<FMultiSelectStyle>? prefixBuilder,
FFieldIconBuilder<FMultiSelectStyle>? suffixBuilder = defaultIconBuilder,
Widget? label,
Widget? description,
bool enabled = true,
ValueChanged<Set<T>>? onChange,
void Function(Set<T>)? onSaved,
AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus,
String? forceErrorText,
String? Function(Set<T>) validator = _defaultValidator,
Widget Function(BuildContext, String) errorBuilder = FFormFieldProperties.defaultErrorBuilder,
Widget? hint,
bool keepHint = true,
int Function(T, T)? sort,
Widget Function(BuildContext, FMultiSelectController<T>, FMultiSelectStyle, T, Widget)? 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 Function(Size, FPortalChildBox, FPortalBox) shift = FPortalShift.flip,
Offset offset = Offset.zero,
FPopoverHideRegion hideRegion = FPopoverHideRegion.excludeChild,
Widget Function(BuildContext, FMultiSelectStyle) contentEmptyBuilder = 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,
}) {
final inverse = {for (final MapEntry(:key, :value) in items.entries) value: key};
return FMultiSelect<T>.rich(
controller: controller,
style: style,
autofocus: autofocus,
focusNode: focusNode,
prefixBuilder: prefixBuilder,
suffixBuilder: suffixBuilder,
label: label,
description: description,
format: (value) => Text(inverse[value] ?? ''),
sort: sort,
tagBuilder: tagBuilder,
enabled: enabled,
onChange: onChange,
onSaved: onSaved,
autovalidateMode: autovalidateMode,
forceErrorText: forceErrorText,
validator: validator,
errorBuilder: errorBuilder,
hint: hint,
keepHint: keepHint,
textAlign: textAlign,
textDirection: textDirection,
clearable: clearable,
anchor: anchor,
fieldAnchor: fieldAnchor,
popoverConstraints: popoverConstraints,
spacing: spacing,
shift: shift,
offset: offset,
hideRegion: hideRegion,
contentEmptyBuilder: contentEmptyBuilder,
contentScrollController: contentScrollController,
contentScrollHandles: contentScrollHandles,
contentPhysics: contentPhysics,
contentDivider: contentDivider,
min: min,
max: max,
initialValue: initialValue,
key: key,
children: [for (final MapEntry(:key, :value) in items.entries) FSelectItem(title: Text(key), value: value)],
);
}