'Is there any special meaning in storing variables into a .env file?
There are people who recommend to use a .env file to store certain values for settings, I use a Dart static class for my constants or setting values, so why to use a .env file? more secure? why? If my Flutter app is intended for Android/IOS/Windows, makes sense?
Solution 1:[1]
From what you're mentioning I understand that you're trying to understand the difference between having values inside a dot env file compared with having those values bundle within your Dart/Flutter project
If that's the case, there is a huge difference between dot env files and hardcoding values inside your codebase.
.envfile
Usually when people use dot env files, the values inside these files are passed to your Flutter application as parameters and the Flutter app reads these parameters during runtime. This means that you can hot-swap these dot env files depending on your choices and environments, etc.
- Hardcoding in the app
When you hardcode values inside your app, they get compiled and shipped with your application meaning that they are more exposed to others.
So depending on the values you want to pass to your app, you can make a decision on whether you want to put those values in dot env files or hardcoded in your app.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vandad Nahavandipoor |
