We are able to stipulate what are the flags and arguments we need to use, such as:
`dart run bin/converter.dart --verbose --out-path="/out" data.json`
2/
This will:
1⃣ Run the converter.dart script
2⃣ With the flag verbose
3⃣ Setting an `out-path` of `/out`
4⃣ Accepting as a last argument the file `data.json`
However, the same cannot be applied to Flutter.
Why?
Because we have no direct control over
`flutter run`
3/
Thankfully Dart provides us a solution 🚀
Using --dart-define in our `flutter run` command we can specify a variable name and its value so that our Dart or Flutter application can use it 🙌
In this example, we define the "ENV" variable and set its value to "stg"
4/
Finally, we can use the `String.fromEnvironment` function to access our variable 🚀
With this we can specify:
🍭 Flavors for the web app
✍️ Misc configurations such as colors, name of the app or baseUrl
🔑 API keys to be injected in a CD step
5/
So now it's your turn! 😁
Have you used --dart-define before? 🤔
What did you use it for?
I'm very curious to know! 🙌
• • •
Missing some Tweet in this thread? You can try to
force a refresh