PlacesAutocompleteField class
A text field like widget to input places with autocomplete.
The autocomplete field calls onChanged with the new address line whenever the user input a new location.
To control the text that is displayed in the text field, use the controller. For example, to set the initial value of the text field, use a controller that already contains some text.
By default, an autocomplete field has a decoration
that draws a divider
below the field. You can use the decoration
property to control the
decoration, for example by adding a label or an icon. If you set the decoration
property to null, the decoration will be removed entirely, including the
extra padding introduced by the decoration to save space for the labels.
If you want the icon to be outside the input field use decoration.icon
.
If it should be inside the field use leading.
To integrate the PlacesAutocompleteField into a Form with other FormField widgets, consider using PlacesAutocompleteFormField.
See also:
- PlacesAutocompleteFormField, which integrates with the Form widget.
- InputDecorator, which shows the labels and other visual elements that surround the actual text editing widget.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PlacesAutocompleteField
Constructors
-
PlacesAutocompleteField({Key? key, required String? apiKey, TextEditingController? controller, Icon? leading, 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<String> ? onChanged, ValueChanged<Prediction> ? onSelected, ValueChanged<PlacesAutocompleteResponse> ? onError, InputDecoration? inputDecoration = const InputDecoration(), Map<String, String> ? headers, BorderRadius? overlayBorderRadius, TextStyle? textStyle, TextStyle? textStyleFormField}) -
Creates a text field like widget.
const
Properties
- apiKey → String?
-
Your Google Maps Places API Key.
final
-
components
→ List<
Component> ? -
final
- controller → TextEditingController?
-
Controls the text being edited.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> ? -
final
- hint → String?
-
Text that is shown, when no input was done, yet.
final
- inputDecoration → InputDecoration?
-
The decoration to show around the text field.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- language → String?
-
final
- leading → Icon?
-
Icon shown inside the field left to the text.
final
- location → Location?
-
final
- mode → Mode
-
final
- offset → num?
-
The position, in the input term, of the last character that the service
uses to match predictions.
final
-
onChanged
→ ValueChanged<
String> ? -
Called when the text being edited changes.
final
-
onError
→ ValueChanged<
PlacesAutocompleteResponse> ? -
Callback when autocomplete has error.
final
-
onSelected
→ ValueChanged<
Prediction> ? -
Called when an autocomplete entry is selected.
final
- overlayBorderRadius → BorderRadius?
-
final
- radius → num?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionToken → String?
-
final
- strictbounds → bool?
-
final
- textStyle → TextStyle?
-
final
- textStyleFormField → TextStyle?
-
final
- trailing → Icon?
-
Icon shown inside the field right to the text.
final
- trailingOnTap → VoidCallback?
-
Callback when trailing is tapped on.
final
-
types
→ List<
String> ? -
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _LocationAutocompleteFieldState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited