I am developing an open source Google Maps project by Flutter and I do not want the GMS API to appear in my repo when I integrate with Google Maps. I don't know how I can use the variable in the .env file in my AppDelegate.swift and AndroidManifest.xml files.
My AndroidManifest.XML
<application
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="MY_API_KEY"/>
</application>
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("MY_API_KEY")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
I added a .env file on my path and I ignore it on .gitignore. Using this method, I could easily use it in my files of lib folder by flutter_dotenv package.