geocoder2
1.5.0, released 2 months ago by flutterbuddy.in
Forward and reverse geocoding using the Google Maps Geocoding API for Flutter and Dart
WASM-ready
What it does
Provides async methods to convert addresses to coordinates and vice versa, returning structured GeoData objects. It handles errors with a custom exception and supports multiple results and optional language selection.
AI-written summary of version 1.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to geocode addresses or coordinates in a Flutter app
- You have a Google Maps API key and want a simple, null‑safe wrapper
- You need to support multiple results or nullable queries
Skip it when
- You prefer an open‑source, no‑API‑key solution like OpenStreetMap
- You need offline geocoding or a different backend
Strengths
- Null‑safe and fully typed API
- Structured exception handling with Google status codes
- Supports multiple results and optional language
- Zero runtime crashes and proper URL encoding
Weaknesses
- Requires a Google Maps API key and billing
- Only supports Google Maps Geocoding API
- No offline mode
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add geocoder2 to pubspec and provide a Google Maps API key in method calls
```dart
import 'package:geocoder2/geocoder2.dart';
try {
GeoData data = await Geocoder2.getDataFromAddress(
address: "277 Bedford Ave, Brooklyn, NY 11211, USA",
googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
);
print("Formatted Address: ${data.address}");
print("Latitude: ${data.latitude}");
print("Longitude: ${data.longitude}");
} on Geocoder2Exception catch (e) {
print("Geocoding failed: ${e.message} (Status: ${e.status})");
}
```Alternatives
Packages that do the same job and could replace geocoder2.