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

Add these permissions before the <application> tag:

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

Important for release builds: The package checks internet connectivity before loading map tiles and performing geocoding searches. Both INTERNET and ACCESS_NETWORK_STATE permissions are required for the app to work properly in release mode.

iOS β€” ios/Runner/Info.plist

Add these keys inside the <dict> tag:

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

Network access: iOS allows network connections by default. For HTTP (non-HTTPS) connections, configure App Transport Security in Info.plist.

macOS β€” macos/Runner/DebugProfile.entitlements & Release.entitlements

Add network client entitlements:

<key>com.apple.security.network.client</key>
<true/>

For location access, also add to macos/Runner/Info.plist:

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

Web

No configuration needed. The package uses:

  • Browser Geolocation API for GPS (requires HTTPS in production)
  • OpenStreetMap tiles and Nominatim API (HTTPS)

Note: HTTP-only domains will not have access to browser geolocation. Deploy with HTTPS or use localhost for development.

Windows & Linux

No additional permissions required. Network access is available by default.

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

Libraries

osm_location_picker
A self-contained Flutter location picker powered by OpenStreetMap.