PlacesAutocompleteFormField constructor
PlacesAutocompleteFormField({
- Key? key,
- required String apiKey,
- TextEditingController? controller,
- Icon? leading,
- String? initialValue,
- String hint = "Search",
- Icon? trailing,
- VoidCallback? trailingOnTap,
- Mode mode = Mode.fullscreen,
- num? offset,
- Location? location,
- num? radius,
- String? language,
- String? sessionToken,
- List<
String> ? types, - List<
Component> ? components, - bool? strictbounds,
- ValueChanged<
PlacesAutocompleteResponse> ? onError, - InputDecoration inputDecoration = const InputDecoration(),
- AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
- FormFieldSetter<
String> ? onSaved, - FormFieldValidator<
String> ? validator,
Creates a FormField that contains a PlacesAutocompleteField.
When a controller is specified, initialValue
must be null (the
default). If controller is null, then a TextEditingController
will be constructed automatically and its text
will be initialized
to initalValue
or the empty string.
For documentation about the various parameters, see the PlacesAutocompleteField class
and new PlacesAutocompleteField
, the constructor.
Implementation
PlacesAutocompleteFormField({
Key? key,
required String apiKey,
this.controller,
Icon? leading,
String? initialValue,
String hint = "Search",
Icon? trailing,
VoidCallback? trailingOnTap,
Mode mode = Mode.fullscreen,
num? offset,
Location? location,
num? radius,
String? language,
String? sessionToken,
List<String>? types,
List<Component>? components,
bool? strictbounds,
ValueChanged<PlacesAutocompleteResponse>? onError,
InputDecoration inputDecoration = const InputDecoration(),
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
FormFieldSetter<String>? onSaved,
FormFieldValidator<String>? validator,
}) : assert(initialValue == null || controller == null),
super(
key: key,
initialValue:
controller != null ? controller.text : (initialValue ?? ''),
onSaved: onSaved,
validator: validator,
autovalidateMode: autovalidateMode,
builder: (FormFieldState<String> field) {
final _TextFormFieldState state = field as _TextFormFieldState;
final InputDecoration? effectiveDecoration = inputDecoration
.applyDefaults(Theme.of(state.context).inputDecorationTheme);
return PlacesAutocompleteField(
key: key,
inputDecoration:
effectiveDecoration?.copyWith(errorText: state.errorText),
controller: state._effectiveController,
apiKey: apiKey,
leading: leading,
trailing: trailing,
offset: offset,
trailingOnTap: trailingOnTap,
hint: hint,
location: location,
radius: radius,
components: components,
language: language,
sessionToken: sessionToken,
types: types,
mode: mode,
strictbounds: strictbounds,
onChanged: state.didChange,
onError: onError,
);
},
);