bigdatacloud_reverse_geocode_client 1.0.1
bigdatacloud_reverse_geocode_client: ^1.0.1 copied to clipboard
Free reverse geocoding for Flutter/Dart — get city, country, and locality from GPS coordinates with automatic IP geolocation fallback. No API key needed.
import 'package:bigdatacloud_reverse_geocode_client/bigdatacloud_reverse_geocode_client.dart';
void main() async {
// Auto-detect location: tries GPS first, falls back to IP geolocation
try {
final location = await GeoLocation.detect();
print('Detected: ${location.city}, ${location.countryName}');
print('Source: ${location.lookupSource}');
print('Coordinates: ${location.latitude}, ${location.longitude}');
} catch (e) {
print('Detection failed: $e');
}
// Reverse geocode specific coordinates
try {
final location = await GeoLocation.reverseGeocode(
latitude: -34.9285,
longitude: 138.6007,
);
print('\nAdelaide lookup:');
print('City: ${location.city}');
print('Country: ${location.countryName} (${location.countryCode})');
print('State: ${location.principalSubdivision}');
print('Locality: ${location.locality}');
print('Postcode: ${location.postcode}');
} catch (e) {
print('Reverse geocode failed: $e');
}
// IP geolocation only (no coordinates)
try {
final location = await GeoLocation.reverseGeocode();
print('\nIP-based location: ${location.city}, ${location.countryName}');
} catch (e) {
print('IP geolocation failed: $e');
}
// Multi-language support
try {
final location = await GeoLocation.reverseGeocode(
latitude: 35.6762,
longitude: 139.6503,
language: 'ja',
);
print('\nTokyo (Japanese): ${location.city}, ${location.countryName}');
} catch (e) {
print('Multi-language lookup failed: $e');
}
}