FMultiSelect<T> constructor
FMultiSelect<T> ({
- required Map<
String, T> items, - FMultiValueControl<
T> ? control, - FPopoverControl popoverControl = const .managed(),
- FMultiSelectStyle style(
- FMultiSelectStyle style
- bool autofocus = false,
- FocusNode? focusNode,
- FFieldIconBuilder<
FMultiSelectStyle> ? prefixBuilder, - FFieldIconBuilder<
FMultiSelectStyle> ? suffixBuilder = defaultIconBuilder, - Widget? label,
- Widget? description,
- bool enabled = true,
- void onSaved(
- Set<
T> values
- Set<
- VoidCallback? onReset,
- AutovalidateMode autovalidateMode = .onUnfocus,
- String? forceErrorText,
- String? validator(
- Set<
T> values
- Set<
- Widget errorBuilder(
- BuildContext context,
- String message
- Widget? hint,
- bool keepHint = true,
- int sort(
- T a,
- T b
- Widget tagBuilder(
- BuildContext context,
- FMultiValueNotifier<
T> controller, - FMultiSelectStyle style,
- T value,
- Widget label,
- TextAlign textAlign = .start,
- TextDirection? textDirection,
- 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 = Offset.zero,
- FPopoverHideRegion contentHideRegion = .excludeChild,
- Object? contentGroupId,
- Widget contentEmptyBuilder(
- BuildContext context,
- FMultiSelectStyle style
- ScrollController? contentScrollController,
- bool contentScrollHandles = false,
- ScrollPhysics contentPhysics = const ClampingScrollPhysics(),
- FItemDivider contentDivider = .none,
- 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,
FMultiValueControl<T>? control,
FPopoverControl popoverControl = const .managed(),
FMultiSelectStyle Function(FMultiSelectStyle style)? style,
bool autofocus = false,
FocusNode? focusNode,
FFieldIconBuilder<FMultiSelectStyle>? prefixBuilder,
FFieldIconBuilder<FMultiSelectStyle>? suffixBuilder = defaultIconBuilder,
Widget? label,
Widget? description,
bool enabled = true,
void Function(Set<T> values)? onSaved,
VoidCallback? onReset,
AutovalidateMode autovalidateMode = .onUnfocus,
String? forceErrorText,
String? Function(Set<T> values) validator = _defaultValidator,
Widget Function(BuildContext context, String message) errorBuilder = FFormFieldProperties.defaultErrorBuilder,
Widget? hint,
bool keepHint = true,
int Function(T a, T b)? sort,
Widget Function(
BuildContext context,
FMultiValueNotifier<T> controller,
FMultiSelectStyle style,
T value,
Widget label,
)?
tagBuilder,
TextAlign textAlign = .start,
TextDirection? textDirection,
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 = Offset.zero,
FPopoverHideRegion contentHideRegion = .excludeChild,
Object? contentGroupId,
Widget Function(BuildContext context, FMultiSelectStyle style) contentEmptyBuilder =
FMultiSelect.defaultContentEmptyBuilder,
ScrollController? contentScrollController,
bool contentScrollHandles = false,
ScrollPhysics contentPhysics = const ClampingScrollPhysics(),
FItemDivider contentDivider = .none,
Key? key,
}) {
final inverse = {for (final MapEntry(:key, :value) in items.entries) value: key};
return .rich(
control: control,
popoverControl: popoverControl,
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,
onSaved: onSaved,
onReset: onReset,
autovalidateMode: autovalidateMode,
forceErrorText: forceErrorText,
validator: validator,
errorBuilder: errorBuilder,
hint: hint,
keepHint: keepHint,
textAlign: textAlign,
textDirection: textDirection,
clearable: clearable,
contentAnchor: contentAnchor,
fieldAnchor: fieldAnchor,
contentConstraints: contentConstraints,
contentSpacing: contentSpacing,
contentOverflow: contentOverflow,
contentOffset: contentOffset,
contentHideRegion: contentHideRegion,
contentGroupId: contentGroupId,
contentEmptyBuilder: contentEmptyBuilder,
contentScrollController: contentScrollController,
contentScrollHandles: contentScrollHandles,
contentPhysics: contentPhysics,
contentDivider: contentDivider,
key: key,
children: [for (final MapEntry(:key, :value) in items.entries) .item(title: Text(key), value: value)],
);
}