Installation
Add the dependency to pubspec.yaml:
dependencies:
flutter_unified_map: ^0.1.0
The platform packages (flutter_unified_map_android, flutter_unified_map_apple, flutter_unified_map_flutter_map)
are endorsed and picked automatically; do not add them yourself.
Before publication: path dependencies
Until the packages are published on pub.dev, depend on a local clone with a path dependency and override every federated package, otherwise pub looks for them on pub.dev:
dependencies:
flutter_unified_map:
path: ../flutter_unified_map/packages/flutter_unified_map
dependency_overrides:
flutter_unified_map_platform_interface:
path: ../flutter_unified_map/packages/flutter_unified_map_platform_interface
flutter_unified_map_android:
path: ../flutter_unified_map/packages/flutter_unified_map_android
flutter_unified_map_apple:
path: ../flutter_unified_map/packages/flutter_unified_map_apple
flutter_unified_map_flutter_map:
path: ../flutter_unified_map/packages/flutter_unified_map_flutter_map
Android: Google Maps API key
Android draws the map with the Google Maps SDK, which needs an API key. Without one the app does not crash: the map shows "Map not configured: API key missing".
Create the key in the Google Cloud console:
- Pick or create a project and link a billing account (required by Google, even though the "Mobile Native Dynamic Maps" SKU used by the Android SDK is free and unlimited).
- Enable Maps SDK for Android (APIs & Services → Library).
- Create an API key (Credentials → Create credentials → API key).
- Recommended: restrict it — Application restrictions → Android apps → your
applicationIdand the SHA-1 of every signing certificate (debug, release, Play App Signing). API restrictions → Maps SDK for Android.
Give the key to the app without committing it. Put it in android/local.properties (already git-ignored):
maps.apiKey=AIza...
or set the MAPS_API_KEY environment variable on CI. Then read it in android/app/build.gradle.kts and pass it to
the manifest:
import java.util.Properties
val mapsApiKey: String = Properties().apply {
val local = rootProject.file("local.properties")
if (local.exists()) local.inputStream().use { load(it) }
}.getProperty("maps.apiKey") ?: System.getenv("MAPS_API_KEY") ?: ""
and in AndroidManifest.xml:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${mapsApiKey}" />
iOS and macOS
No key, no setup: Apple MapKit works out of the box on iOS and macOS.
Web, Windows, Linux
Nothing to configure: the flutter_map backend renders OpenStreetMap tiles. Remember the OSM tile usage policy for production apps.