FormBuilderTypeAhead<T> constructor
FormBuilderTypeAhead<T> ({
- Key? key,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- FocusNode? focusNode,
- FormFieldSetter<
T> ? onSaved, - FormFieldValidator<
T> ? validator, - InputDecoration decoration = const InputDecoration(),
- T? initialValue,
- ValueChanged<
T?> ? onChanged, - ValueTransformer<
T?> ? valueTransformer, - VoidCallback? onReset,
- required String name,
- required ItemBuilder<
T> itemBuilder, - required SuggestionsCallback<
T> suggestionsCallback, - Duration animationDuration = const Duration(milliseconds: 500),
- double animationStart = 0.25,
- bool autoFlipDirection = false,
- TextEditingController? controller,
- Duration debounceDuration = const Duration(milliseconds: 300),
- AxisDirection direction = AxisDirection.down,
- ErrorBuilder? errorBuilder,
- bool getImmediateSuggestions = false,
- bool hideKeyboard = false,
- bool hideOnEmpty = false,
- bool hideOnError = false,
- bool hideOnLoading = false,
- bool hideSuggestionsOnKeyboardHide = true,
- bool keepSuggestionsOnLoading = true,
- bool keepSuggestionsOnSuggestionSelected = false,
- WidgetBuilder? loadingBuilder,
- WidgetBuilder? noItemsFoundBuilder,
- SuggestionSelectionCallback<
T> ? onSuggestionSelected, - ScrollController? scrollController,
- SelectionToTextTransformer<
T> ? selectionToTextTransformer, - SuggestionsBoxController? suggestionsBoxController,
- SuggestionsBoxDecoration suggestionsBoxDecoration = const SuggestionsBoxDecoration(),
- double suggestionsBoxVerticalOffset = 5.0,
- TextFieldConfiguration textFieldConfiguration = const TextFieldConfiguration(),
- AnimationTransitionBuilder? transitionBuilder,
- bool autoFlipListDirection = true,
- double autoFlipMinHeight = 64.0,
- bool hideKeyboardOnDrag = false,
- bool intercepting = false,
- IndexedWidgetBuilder? itemSeparatorBuilder,
- LayoutArchitecture? layoutArchitecture,
- int minCharsForSuggestions = 0,
- void onSuggestionsBoxToggle()?,
Creates text field that auto-completes user input from a list of items
Implementation
FormBuilderTypeAhead({
super.key,
super.autovalidateMode,
super.enabled,
super.focusNode,
super.onSaved,
super.validator,
super.decoration,
super.initialValue,
super.onChanged,
super.valueTransformer,
super.onReset,
required super.name,
required this.itemBuilder,
required this.suggestionsCallback,
this.animationDuration = const Duration(milliseconds: 500),
this.animationStart = 0.25,
this.autoFlipDirection = false,
this.controller,
this.debounceDuration = const Duration(milliseconds: 300),
this.direction = AxisDirection.down,
this.errorBuilder,
this.getImmediateSuggestions = false,
this.hideKeyboard = false,
this.hideOnEmpty = false,
this.hideOnError = false,
this.hideOnLoading = false,
this.hideSuggestionsOnKeyboardHide = true,
this.keepSuggestionsOnLoading = true,
this.keepSuggestionsOnSuggestionSelected = false,
this.loadingBuilder,
this.noItemsFoundBuilder,
this.onSuggestionSelected,
this.scrollController,
this.selectionToTextTransformer,
this.suggestionsBoxController,
this.suggestionsBoxDecoration = const SuggestionsBoxDecoration(),
this.suggestionsBoxVerticalOffset = 5.0,
this.textFieldConfiguration = const TextFieldConfiguration(),
this.transitionBuilder,
this.autoFlipListDirection = true,
this.autoFlipMinHeight = 64.0,
this.hideKeyboardOnDrag = false,
this.ignoreAccessibleNavigation = false,
this.intercepting = false,
this.itemSeparatorBuilder,
this.layoutArchitecture,
this.minCharsForSuggestions = 0,
this.onSuggestionsBoxToggle,
}) : assert(T == String || selectionToTextTransformer != null),
super(
builder: (FormFieldState<T?> field) {
final state = field as FormBuilderTypeAheadState<T>;
final theme = Theme.of(state.context);
return TypeAheadField<T>(
textFieldConfiguration: textFieldConfiguration.copyWith(
enabled: state.enabled,
controller: state._typeAheadController,
style: state.enabled
? textFieldConfiguration.style
: theme.textTheme.titleMedium!.copyWith(
color: theme.disabledColor,
),
focusNode: state.effectiveFocusNode,
decoration: state.decoration,
),
autoFlipListDirection: autoFlipListDirection,
autoFlipMinHeight: autoFlipMinHeight,
hideKeyboardOnDrag: hideKeyboardOnDrag,
ignoreAccessibleNavigation: ignoreAccessibleNavigation,
intercepting: intercepting,
itemSeparatorBuilder: itemSeparatorBuilder,
layoutArchitecture: layoutArchitecture,
minCharsForSuggestions: minCharsForSuggestions,
onSuggestionsBoxToggle: onSuggestionsBoxToggle,
// TODO HACK to satisfy strictness
suggestionsCallback: suggestionsCallback,
itemBuilder: itemBuilder,
transitionBuilder: (context, suggestionsBox, controller) =>
suggestionsBox,
onSuggestionSelected: (T suggestion) {
state.didChange(suggestion);
onSuggestionSelected?.call(suggestion);
},
getImmediateSuggestions: getImmediateSuggestions,
errorBuilder: errorBuilder,
noItemsFoundBuilder: noItemsFoundBuilder,
loadingBuilder: loadingBuilder,
debounceDuration: debounceDuration,
suggestionsBoxDecoration: suggestionsBoxDecoration,
suggestionsBoxVerticalOffset: suggestionsBoxVerticalOffset,
animationDuration: animationDuration,
animationStart: animationStart,
direction: direction,
hideOnLoading: hideOnLoading,
hideOnEmpty: hideOnEmpty,
hideOnError: hideOnError,
hideSuggestionsOnKeyboardHide: hideSuggestionsOnKeyboardHide,
keepSuggestionsOnLoading: keepSuggestionsOnLoading,
autoFlipDirection: autoFlipDirection,
suggestionsBoxController: suggestionsBoxController,
keepSuggestionsOnSuggestionSelected:
keepSuggestionsOnSuggestionSelected,
hideKeyboard: hideKeyboard,
scrollController: scrollController,
);
},
);