flutter google maps tutorial
setup
- get an api key at https://cloud.google.com/maps-platform/
- enable maps sdk for android, maps sdk for ios, and directions api.
- add your api key to the specified files
android/app/src/main/androidmanifest.xml
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.api_key"
android:value="your key here"/>
ios/runner/appdelegate.swift
import uikit
import flutter
import googlemaps
@uiapplicationmain
@objc class appdelegate: flutterappdelegate {
override func application(
_ application: uiapplication,
didfinishlaunchingwithoptions launchoptions: [uiapplication.launchoptionskey: any]?
) -> bool {
gmsservices.provideapikey("your key here")
generatedpluginregistrant.register(with: self)
return super.application(application, didfinishlaunchingwithoptions: launchoptions)
}
}
lib/.env.dart
const string googleapikey = 'your key here';
Comments are closed.