패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소flutterbuddy1/geocoder2

geocoder2

flutterbuddy1/geocoder2 open-source repository details.

geocoder2 프로젝트 이미지
스타
4
포크
27
최근 푸시(UTC)
2026. 9. 18.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

geocoder2

Easy forward and reverse geocoding from the Google Maps Geocoding API for Flutter & Dart.

Make sure to enable the Geocoding API for your project in the Google Cloud Console.


Features

  • 🚀 Modern & Compatible: Supports Flutter 3.x and Dart 3.x with http: ">=0.13.4 <2.0.0".
  • 🔍 Forward Geocoding: Convert address strings into coordinates and structured location data.
  • 📍 Reverse Geocoding: Convert latitude and longitude coordinates into human-readable addresses.
  • 📋 Multiple Results Support: Retrieve all matching address candidates via getAllDataFromAddress / getAllDataFromCoordinates.
  • 🛡️ Zero Runtime Crashes: Full null-safety protection against missing fields, unknown location types, and empty results.
  • ⚠️ Clear Exception Handling: Structured Geocoder2Exception provides Google API status codes (REQUEST_DENIED, OVER_QUERY_LIMIT, ZERO_RESULTS, etc.) and error messages.
  • 🌐 Localization: Request address components in your preferred language using the optional language parameter.

Installation

Add geocoder2 to your pubspec.yaml:

dependencies:
  geocoder2: ^1.5.0

Code Examples

import 'package:geocoder2/geocoder2.dart';
Reverse Geocoding (Coordinates to Address)
try {
  GeoData data = await Geocoder2.getDataFromCoordinates(
    latitude: 40.714224,
    longitude: -73.961452,
    googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
    language: "en", // Optional language code
  );

  print("Address: ${data.address}");
  print("City: ${data.city}");
  print("State: ${data.state}");
  print("Country: ${data.country} (${data.countryCode})");
  print("Postal Code: ${data.postalCode}");
  print("Street Number: ${data.streetNumber}");
  print("Latitude: ${data.latitude}");
  print("Longitude: ${data.longitude}");
} on Geocoder2Exception catch (e) {
  print("Geocoding failed: ${e.message} (Status: ${e.status})");
}
Forward Geocoding (Address to Coordinates)
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}");
  print("City: ${data.city}");
} on Geocoder2Exception catch (e) {
  print("Geocoding failed: ${e.message} (Status: ${e.status})");
}
Get Multiple Address Matches
List<GeoData> results = await Geocoder2.getAllDataFromAddress(
  address: "Springfield",
  googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
);

for (var result in results) {
  print("${result.address} -> (${result.latitude}, ${result.longitude})");
}
Safe Nullable Queries

If you prefer null over catching an exception when no results exist:

GeoData? data = await Geocoder2.getDataFromAddressOrNull(
  address: "Some Rare Location",
  googleMapApiKey: "YOUR_GOOGLE_MAP_API_KEY",
);

if (data != null) {
  print("Found: ${data.address}");
} else {
  print("No address found.");
}

Language Support

Both forward and reverse methods support an optional language parameter. See the list of supported Google Maps language codes.


Alternative (OpenStreetMap / No API Key)

If you do not have a Google Maps API Key or want to use free OpenStreetMap Nominatim, check out geocoder_buddy.


Buy Me A Coffee

Buy Me A Coffee
Mayank Diwakar GitHub avatar
GitHub 작성자

Mayank Diwakar ↗

Full-Stack Developer | Building modern, scalable applications with Flutter, React, Node.js, Laravel, PHP & more. 🚀

언어Dart

사용 중인 의존성

의존성 목록 4 개

  • flutter{"sdk":"flutter"}
  • http>=0.13.4 <2.0.0
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗