Why does the .env file get added to build/web/assets?

Viewed 264

I'm using flutter_dotenv to manage some API keys - https://pub.dev/packages/flutter_dotenv

According to the instructions I should add the .env file to assets in pubspec.yaml but when I run flutter build web it adds the .env file to the build for deployment. This doesn't seem correct to me because the .env file should not get deployed anywhere publicly from what I understand.

1 Answers

I had the same issue, and solved it by renaming .env.* files to env.*.

https://pub.dev/packages/flutter_dotenv#usage

Note: If deploying to web server, ensure that the config file is uploaded and not ignored. (Whitelist the config file on the server, or name the config file without a leading .)

Related