Config Build Flavor on Flutter
After adding environments for Ios and Android platform we need to config on Flutter project with some information like API_URL for staging, nightly, and production.
Create EnvironmentDefault class like this:
Create Environment Nightly, Staging, Production extends EnvironmentDefault
Nightly:
Staging:
Production:
Create 3 main classes called:
main_stg.dart with environment staging
main_nightly.dart with environment nightly
main_production.dart with environment production
In your code, if you need to get API_URL for the right environment just use:
Build the project with your flavor, and open "Edit configurations" in Android Studio:
Done!!
Last updated