Skip to content

Commit f3b336d

Browse files
feat: add new properties to FormBuilderTypeAhead
1 parent 0ee9a3c commit f3b336d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

lib/src/fields/form_builder_typeahead.dart

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,52 @@ class FormBuilderTypeAhead<T> extends FormBuilderFieldDecoration<T> {
259259

260260
final ScrollController? scrollController;
261261

262+
final IndexedWidgetBuilder? itemSeparatorBuilder;
263+
264+
/// By default, we render the suggestions in a ListView, using
265+
/// the `itemBuilder` to construct each element of the list. Specify
266+
/// your own `layoutArchitecture` if you want to be responsible
267+
/// for layinng out the widgets using some other system (like a grid).
268+
final LayoutArchitecture? layoutArchitecture;
269+
270+
/// Used to overcome [Flutter issue 98507](https://github.com/flutter/flutter/issues/98507)
271+
/// Most commonly experienced when placing the [TypeAheadFormField] on a google map in Flutter Web.
272+
final bool intercepting;
273+
274+
/// If set to false, suggestion list will not be reversed according to the
275+
/// [autoFlipDirection] property.
276+
///
277+
/// Defaults to true.
278+
final bool autoFlipListDirection;
279+
280+
/// Minimum height below [autoFlipDirection] is triggered
281+
///
282+
/// Defaults to 64.0.
283+
final double autoFlipMinHeight;
284+
285+
/// The minimum number of characters which must be entered before
286+
/// [suggestionsCallback] is triggered.
287+
///
288+
/// Defaults to 0.
289+
final int minCharsForSuggestions;
290+
291+
/// If set to true and if the user scrolls through the suggestion list, hide the keyboard automatically.
292+
/// If set to false, the keyboard remains visible.
293+
/// Throws an exception, if hideKeyboardOnDrag and hideSuggestionsOnKeyboardHide are both set to true as
294+
/// they are mutual exclusive.
295+
///
296+
/// Defaults to false
297+
final bool hideKeyboardOnDrag;
298+
299+
/// Allows a bypass of a problem on Flutter 3.7+ with the accessibility through Overlay
300+
/// that prevents flutter_typeahead to register a click on the list of suggestions properly.
301+
///
302+
/// Defaults to false
303+
final bool ignoreAccessibleNavigation;
304+
305+
// Adds a callback for the suggestion box opening or closing
306+
final void Function(bool)? onSuggestionsBoxToggle;
307+
262308
/// Creates text field that auto-completes user input from a list of items
263309
FormBuilderTypeAhead({
264310
super.key,
@@ -300,6 +346,15 @@ class FormBuilderTypeAhead<T> extends FormBuilderFieldDecoration<T> {
300346
this.suggestionsBoxVerticalOffset = 5.0,
301347
this.textFieldConfiguration = const TextFieldConfiguration(),
302348
this.transitionBuilder,
349+
this.autoFlipListDirection = true,
350+
this.autoFlipMinHeight = 64.0,
351+
this.hideKeyboardOnDrag = false,
352+
this.ignoreAccessibleNavigation = false,
353+
this.intercepting = false,
354+
this.itemSeparatorBuilder,
355+
this.layoutArchitecture,
356+
this.minCharsForSuggestions = 0,
357+
this.onSuggestionsBoxToggle,
303358
}) : assert(T == String || selectionToTextTransformer != null),
304359
super(
305360
builder: (FormFieldState<T?> field) {
@@ -318,6 +373,15 @@ class FormBuilderTypeAhead<T> extends FormBuilderFieldDecoration<T> {
318373
focusNode: state.effectiveFocusNode,
319374
decoration: state.decoration,
320375
),
376+
autoFlipListDirection: autoFlipListDirection,
377+
autoFlipMinHeight: autoFlipMinHeight,
378+
hideKeyboardOnDrag: hideKeyboardOnDrag,
379+
ignoreAccessibleNavigation: ignoreAccessibleNavigation,
380+
intercepting: intercepting,
381+
itemSeparatorBuilder: itemSeparatorBuilder,
382+
layoutArchitecture: layoutArchitecture,
383+
minCharsForSuggestions: minCharsForSuggestions,
384+
onSuggestionsBoxToggle: onSuggestionsBoxToggle,
321385
// TODO HACK to satisfy strictness
322386
suggestionsCallback: suggestionsCallback,
323387
itemBuilder: itemBuilder,

0 commit comments

Comments
 (0)