osm_location_picker 1.0.2 copy "osm_location_picker: ^1.0.2" to clipboard
osm_location_picker: ^1.0.2 copied to clipboard

A self-contained Flutter location picker powered by OpenStreetMap. No API key required. Supports address search, GPS, and full theming.

osm_location_picker #

pub package Flutter Platforms License: MIT

A self-contained Flutter location picker powered by OpenStreetMap.

No API key. No account. No billing. Everything runs on free, open-source map and geocoding services β€” making this package a great fit for small projects, prototypes, and indie apps that don't want the overhead of registering with Google Maps or Mapbox.

Users can pan/zoom the map, search for addresses, and tap to confirm a location. The package returns a LocationModel containing the selected address string and LatLng coordinates.

Features #

  • πŸ—ΊοΈ Interactive map using flutter_map + OpenStreetMap tiles
  • πŸ” Address search powered by the Nominatim geocoding service
  • πŸ“ Jump to the device's current GPS location with one tap
  • 🎨 Fully themeable via LocationPickerTheme
  • 🌐 Built-in Arabic and English UI strings β€” extend with LocationPickerStrings
  • πŸ—οΈ BLoC/Cubit state management β€” no global state pollution
  • πŸ“¦ Zero external API keys needed

Platform support #

Platform Supported Notes
Android βœ… Full support
iOS βœ… Full support
Web βœ… Location uses browser Geolocation API β€” HTTPS required
macOS βœ… Full support
Windows βœ… Full support
Linux βœ… Full support

Note: GPS / current-location features depend on the location package. On platforms where device location is unavailable or denied, the map still opens and the user can search or tap a location manually β€” so the picker always works regardless of permission status.

Getting started #

1. Add the dependency #

dependencies:
  osm_location_picker:
    path: ../ # or the pub.dev version once published

2. Platform permissions #

Android β€” android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

iOS β€” ios/Runner/Info.plist

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to your location to show it on the map.</string>

Usage #

Push LocationPickerView as a full-screen route. It returns a LocationModel? when the user confirms a location.

import 'package:osm_location_picker/osm_location_picker.dart';

// Open the picker
final LocationModel? result = await Navigator.of(context).push<LocationModel>(
  MaterialPageRoute(
    builder: (_) => const LocationPickerView(),
  ),
);

if (result != null) {
  print(result.address);               // "Baghdad, Iraq"
  print(result.latLng?.latitude);      // 33.315241
  print(result.latLng?.longitude);     // 44.366085
}

Restore a previously selected location #

LocationPickerView(
  initialLatLng: LatLng(33.315241, 44.366085),
  initialAddress: 'Baghdad, Iraq',
)

Custom theme #

LocationPickerView(
  theme: LocationPickerTheme(
    primaryColor: Colors.teal,
    backgroundColor: Colors.white,
  ),
)

Use LocationPickerTheme.of(context) to derive colours from your app's ThemeData automatically.

Custom strings / localisation #

LocationPickerView(
  strings: LocationPickerStrings(
    title: 'Pick a spot',
    confirmLocation: 'Use this location',
    searchHint: 'Search address…',
    // … all fields required
  ),
)

Built-in factories: LocationPickerStrings.en() and LocationPickerStrings.ar(). LocationPickerStrings.of(context) picks one automatically based on Localizations.localeOf(context).

LocationModel #

Field Type Description
address String? Human-readable address from Nominatim
latLng LatLng? Coordinates (latlong2 package)
// Serialise / deserialise
final json = model.toJson();
final model2 = LocationModel.fromJson(json);

Additional information #

  • Map tiles Β© OpenStreetMap contributors
  • Geocoding provided by Nominatim β€” please respect the usage policy
  • File bugs and feature requests on the project's issue tracker
  • Contributions are welcome β€” open a pull request with tests and a description of the change
0
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A self-contained Flutter location picker powered by OpenStreetMap. No API key required. Supports address search, GPS, and full theming.

Repository (GitHub)
View/report issues

Topics

#map #location #geocoding #openstreetmap #gps

License

unknown (license)

Dependencies

dio, equatable, flutter, flutter_bloc, flutter_map, flutter_svg, geolocator, internet_connection_checker_plus, latlong2, lottie

More

Packages that depend on osm_location_picker