Prediction class

Data model representing a single place prediction from Google Places Autocomplete API.

Contains detailed information about a predicted place including its description, place ID, matched substrings, structured formatting, terms, and types. This model is used as part of the PlaceAutoComplete response.

Key fields:

  • description: Full textual description of the place
  • placeId: Unique identifier for the place (used for Place Details requests)
  • structuredFormatting: Broken-down parts of the description (main text and secondary text)
  • types: Categories/types of the place (e.g., "restaurant", "locality")

Example usage:

final prediction = Prediction.fromJson(apiResponse);
print('Place: ${prediction.description}');
print('Place ID: ${prediction.placeId}');
print('Main text: ${prediction.structuredFormatting?.mainText}');

See also:

Constructors

Prediction({String? description = "", String? id = "", List<MatchedSubstring>? matchedSubstrings, String? placeId = "", String? reference = "", StructuredFormatting? structuredFormatting, List<Term>? terms, List<String>? types})
Creates a Prediction instance.
Prediction.fromJson(Map<String, dynamic> json)
Creates a Prediction from JSON data returned by Google Places API.
factory

Properties

description String?
Full text description of the predicted place
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id String?
Deprecated stable ID (use placeId instead)
getter/setter pair
matchedSubstrings List<MatchedSubstring>?
Substrings in the description that match the user's input
getter/setter pair
placeId String?
Unique identifier for this place (use for Place Details API)
getter/setter pair
reference String?
Deprecated reference value
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
structuredFormatting StructuredFormatting?
Structured breakdown of main and secondary text
getter/setter pair
terms List<Term>?
Individual terms/words in the description with offsets
getter/setter pair
types List<String>?
Place categories/types (e.g., "restaurant", "street_address")
getter/setter pair

Methods

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

Operators

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