Flutter Google Maps API Package
This package seamlessly integrates the Google Maps API into your Flutter application, offering type-safe requests and responses, complemented with versatile widgets.
Features
API
The package provides fully type-safe request and response handling for the following Google Maps API endpoints:
-
Places API
:- Autocomplete
- Details
- Search (Upcoming)
- Photos (Upcoming)
-
Geocoding
:- Geocode (Upcoming)
- Reverse Geocoding (Upcoming)
-
Routes
:- Various functionalities (Upcoming)
Widgets
In addition to API integration, this package offers customizable widgets leveraging these APIs, such as:
- Place Autocomplete Widget
Getting Started
- Obtain an API key from Google Cloud Console.
- Ensure the key is enabled for
WEB Requests
since the package uses HTTP requests to interact with the APIs. - Install the latest version of this package using:
flutter pub add google_maps_api
Usage
Initialize the API with your key:
final googleMapsApi = GoogleMapsApi(apiKey: "YOUR_API_KEY");
Example usage for retrieving place details:
final googleMapsApi = GoogleMapsApi(apiKey: "YOUR_API_KEY");
PlacesDetailsResponse response = await googleMapsApi.places.details(
placeId: "ChIJN1t_tDeuEmsRUsoyG83frY4",
);
if (response.status == PlacesDetailsStatus.OK) {
print(response.place);
}
Widget example:
PlaceAutocomplete(
onSelected: (selection) {
setState(() {
_selection = selection;
});
},
apiKey: "YOUR_API_KEY",
),
For more examples, refer to the /example
directory, which includes a comprehensive sample application.
Additional Information
Contributing
As the Google Maps API encompasses numerous endpoints, contributions are highly appreciated to expand and enhance this package.
If you find this package useful, please give it a like and star it on GitHub to support its popularity!
Libraries
- generic/address_component
- generic/bounds
- generic/geometry
- generic/plus_code
- google_maps_api
- places/autocomplete/autocomplete
- places/autocomplete/request/place_autocomplete_request_options
- places/autocomplete/response/place_autocomplete_matched_substring
- places/autocomplete/response/place_autocomplete_prediction
- places/autocomplete/response/place_autocomplete_response
- places/autocomplete/response/place_autocomplete_structured_format
- places/autocomplete/response/place_autocomplete_term
- places/autocomplete/response/places_autocomplete_status
- places/details/details
- places/details/request/place_details_request_options
- places/details/response/place
- places/details/response/place_details_response
- places/details/response/place_details_status
- places/details/response/place_editorial_summary
- places/details/response/place_opening_hours
- places/details/response/place_opening_hours_period
- places/details/response/place_opening_hours_period_detail
- places/details/response/place_photo
- places/details/response/place_review
- places/details/response/place_special_day
- places/places
- widgets/autocomplete/debounce
- widgets/autocomplete/place_autocomplete