places_sdk_flutter 0.0.3
places_sdk_flutter: ^0.0.3 copied to clipboard
Flutter plugin wrapping the official Google Places SDK on Android and iOS (autocomplete search + place details).
places_sdk_flutter #
Flutter plugin that wraps the Places SDK for Android and Places SDK for iOS. Requests run through the native SDKs (not the HTTP Places Web Service).
Published on pub.dev as places_sdk_flutter (the name google_places_flutter is already used by another package that calls the HTTP API).
Disclaimer: This is an unofficial package and is not affiliated with, endorsed by, or sponsored by Google.
Setup #
-
Enable Places API (New) in Google Cloud Console.
-
Create an API key and restrict it:
- Android: package name + SHA-1
- iOS: bundle identifier
-
Add the key to your app (recommended — no key in Dart):
Android — inside
<application>inAndroidManifest.xml:<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_PLACES_API_KEY" />iOS — in
Info.plist:<key>GMSApiKey</key> <string>YOUR_PLACES_API_KEY</string> -
Android:
minSdk24+ (plugin default). UsesPlaces.initializeWithNewPlacesApiEnabled. -
iOS: deployment target 14.0+. CocoaPods pulls
GooglePlaces(~> 8.5).
Usage #
Add to pubspec.yaml:
dependencies:
places_sdk_flutter: ^0.0.3
import 'package:places_sdk_flutter/places_sdk_flutter.dart';
// Autocomplete (API key read from AndroidManifest / Info.plist)
final predictions = await searchPlace(
query: 'coffee shop',
countryCode: 'US', // optional ISO 3166-1 alpha-2
limit: 5,
);
// Place details
final details = await getPlaceDetails(
placeId: predictions.first.placeId,
);
print(details.name);
print(details.formattedAddress);
print(details.latitude);
API #
| Function | Native call |
|---|---|
searchPlace |
Android: findAutocompletePredictions · iOS: findAutocompletePredictions |
getPlaceDetails |
Android: fetchPlace · iOS: fetchPlace(fromPlaceID:) |
Models: PlacePrediction, PlaceDetails, AddressComponent.
PlaceDetails.addressComponents uses the standard Google Places shape (long_name, short_name, types) and is always a list (empty when unavailable).
Example app #
cd example
# Set YOUR_PLACES_API_KEY in example/android/.../AndroidManifest.xml
# and example/ios/Runner/Info.plist, then:
flutter run
Notes #
- Autocomplete (New) on Android returns up to 5 predictions per request;
limitonly trims that list on the Dart side. - Billing follows Google Places SDK pricing; the plugin requests a fixed field set for details (name, address, location, phone, website, rating, hours, types, etc.).
- Show required attributions when displaying Google place data in your UI.