从Flutter中的.env文件将api密钥加载到AndroidManifest.xml [英] Load api key to AndroidManifest.xml from .env file in flutter
问题描述
我正在使用 flutter_dotenv
[ https://pub.dev/packages/flutter_dotenv] 包,并定义一个 .env
文件来定义我的环境变量.但是,对于使用Google Maps,我还必须在 AndroidManifest.xml
文件中使用maps apikey.是否可以从 flutter_dotenv
包的 .env
文件中读取地图apikey,而不是在 AndroidManifest.xml
文件中对apikey进行硬编码?>
I am using the flutter_dotenv
[https://pub.dev/packages/flutter_dotenv] package and defines a .env
file to define my environment variables. But for using google maps I also have to use maps apikey in AndroidManifest.xml
file. Is it possible to read the maps apikey from .env
file of the flutter_dotenv
package instead of hardcoding the apikey in AndroidManifest.xml
file?
推荐答案
下面的视频很好地解释了如何从Flutter中的.env文件将API密钥加载到AndroidManifest.xml.
The below video has a nice explanation of how we can Load API key to AndroidManifest.xml from the .env file in Flutter.
这里的变化是,我们需要添加一个不同的插件以使其起作用,并按照视频教程中提到的步骤进行操作.
The change here is, we need to add a different plugin to make it work and follow the steps mentioned in the video tutorial.
插件 https://pub.dev/packages/flutter_config
视频 https://www.youtube.com/watch?v=OtkrNQxJzBQ
Github https://github.com/ByneappLLC/flutter_config/blob/master/doc/ANDROID.md
这篇关于从Flutter中的.env文件将api密钥加载到AndroidManifest.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!