google_places_search_field 1.0.2
google_places_search_field: ^1.0.2 copied to clipboard
A customizable Flutter widget for searching locations using Google Places Autocomplete with LatLng callback support
A Flutter widget that integrates with the flutter_google_places_sdk and google_maps_flutter to provide a search input field with Google Places autocomplete and LatLng callback support. Ideal for apps that need smooth location search functionality.
Features #
- Google Places autocomplete integration
- Real-time search with debouncing
- Customizable input decoration and text style
- Easy retrieval of selected location's coordinates (
LatLng) - Clean overlay UI with search suggestions
Getting started #
Prerequisites #
- Enable the Places API and Maps SDK for Android/iOS in Google Cloud Console.
- Add your API key with the required restrictions.
Installation #
In your pubspec.yaml, add:
dependencies:
flutter:
sdk: flutter
# Add the latest version
flutter_google_places_sdk:
# Add the latest version
google_maps_flutter:
# This package (use latest)
google_places_search_field:
Preview #
Platform Support #
| Platform | Supported |
|---|---|
| Android | ✅ Yes |
| iOS | ✅ Yes |
| Web | ❌ No |
| macOS | ⚠️ Untested |
| Windows | ⚠️ Untested |
| Linux | ⚠️ Untested |
❗️ This package does not support Flutter Web due to limitations in
flutter_google_places_sdkandgoogle_maps_flutter. Consider usinggoogle_maps_webserviceor a platform-channel implementation for web-specific use cases.
Usage #
GooglePlacesSearchField(
apiKey: 'YOUR_GOOGLE_API_KEY',
onLatLngSelected: (LatLng latLng) {
print('Selected location: ${latLng.latitude}, ${latLng.longitude}');
},
hintText: 'Search for a place',
);