Environment variables are cool. On the server side you can set some environment variables which will let you switch some functionality or value when deploying to production.
The answer is ".fromEnvironment". For String and bool datatypes, Dart gives you a constant constructor called
fromEnvironment that reads the environment variable and sets it to your constant.
bool isRelease = const bool.fromEnvironment("releasemode");
But how do you populate "releasemode"?
When you run
pub build, simply pass in the environment variable as such:
pub build --define releasemode=true
And voila! You have environment variables on the front end!
Now that is pretty cool.
The possibilities are endless. Personally, I use it to switch from a stage endpoint to a production endpoint when I deploy, but you can use it for anything!