FormAutocomplete<T extends Object> constructor

FormAutocomplete<T extends Object>({
  1. Key? key,
  2. required AutocompleteOptionsBuilder<T> optionsBuilder,
  3. AutocompleteOptionToString<T>? displayStringForOption,
  4. AutocompleteFieldViewBuilder? fieldViewBuilder,
  5. AutocompleteOnSelected<T>? onSelected,
  6. double optionsMaxHeight = 200.0,
  7. AutocompleteOptionsViewBuilder<T>? optionsViewBuilder,
  8. T? initialValue,
})

Implementation

FormAutocomplete({
  Key? key,
  required AutocompleteOptionsBuilder<T> optionsBuilder,
  AutocompleteOptionToString<T>? displayStringForOption,
  AutocompleteFieldViewBuilder? fieldViewBuilder,
  AutocompleteOnSelected<T>? onSelected,
  double optionsMaxHeight = 200.0,
  AutocompleteOptionsViewBuilder<T>? optionsViewBuilder,
  T? initialValue,
}) : super(
    key: key,
    initialValue: initialValue,
    builder: (FormFieldState<T> field) {
      final _FormAutocompleteState state = field as _FormAutocompleteState;
      void onChangedHandler(T value) {
        state.didChange(value);
        if (onSelected != null) {
          onSelected(state.value);
        }
      }
      return Autocomplete<T>(
          key: state.key,
          optionsBuilder: optionsBuilder,
          displayStringForOption: displayStringForOption ?? RawAutocomplete.defaultStringForOption,
          fieldViewBuilder: fieldViewBuilder ?? Autocomplete(optionsBuilder: optionsBuilder).fieldViewBuilder,
          optionsMaxHeight: optionsMaxHeight,
          optionsViewBuilder: optionsViewBuilder,
          initialValue: TextEditingValue(text: state.value ?? ''),
          onSelected: (v) {
            onChangedHandler(v);
          }
        );
    }
);