PlaceAutoComplete class

Data model representing the response from Google Places Autocomplete API.

Contains a list of place predictions and the API response status. This is the top-level response object returned when querying the autocomplete endpoint.

Example usage:

final response = await apiClient.getPlaceAutocomplete(input: 'Pizza');
final autoComplete = PlaceAutoComplete.fromJson(response.data);

if (autoComplete.status == 'OK') {
  for (var prediction in autoComplete.predictions!) {
    print(prediction.description);
  }
}

Status values:

  • OK: Successful response with results
  • ZERO_RESULTS: No predictions found
  • INVALID_REQUEST: Invalid parameters
  • REQUEST_DENIED: API key issues
  • UNKNOWN_ERROR: Server error

See also:

Constructors

PlaceAutoComplete({List<Prediction>? predictions, String status = ""})
Creates a PlaceAutoComplete instance.
PlaceAutoComplete.fromJson(Map<String, dynamic> json)
Creates a PlaceAutoComplete from Google Places API JSON response.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
predictions List<Prediction>?
List of place predictions returned by the API
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status String
API response status (e.g., "OK", "ZERO_RESULTS")
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the PlaceAutoComplete to JSON format.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited