In this video, we will see how to setup and use environment variables with Flutter. We will not be using any package to handle this.
Working with environment variables flutter By Codefarmer
-
Load environment variables from file.
flutter run --dart-define-from-file=lib/config/config.json
-
Setup VSCode Debugger to autoload the env file. add
toolArgs
parameters--dart-define-from-file
PATH/TO/ENV/FILE
to launch.json file.{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "development", "request": "launch", "type": "dart", "toolArgs": [ "--dart-define-from-file", "lib/env/development.env" ] }, { "name": "production", "request": "launch", "type": "dart", "flutterMode": "release", "toolArgs": [ "--dart-define-from-file", "lib/env/production.env" ] }, { "name": "working_with_environment_variables_flutter (profile mode)", "request": "launch", "type": "dart", "flutterMode": "profile" }, { "name": "working_with_environment_variables_flutter (release mode)", "request": "launch", "type": "dart", "flutterMode": "release" } ] }
-
Thiloka Viraj @thilokaviraj
thilokaviraj.github.io | twitter.com/thilokaviraj | youtube.com/@thilokaviraj
Get in touch with the project developers and the community through our GitHub Discussions forum. View contributing.md for information.
Bug reports and feature requests can be submitted on the Github Issues.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code of Conduct.
This work is distributed under the Do What The F*ck You Want To Public License License. See license for more information.
- ✅ Commercial use
- ✅ Distribution
- ✅ Modification
- ⛔
Patent use - ✅ Private use
- ⛔
Disclose source - ⛔
License and copyright notice - ⛔
Network use is distribution - ⛔
Same license - ⛔
State changes
- ❌ Liability
- ⛔
Trademark use - ❌ Warranty
- Copyright © 2024 Thiloka Viraj @thilokaviraj.
- Copyright © 2024 Contributors.