I need to run my Flutter app in multiple backend environments. For instance
DEV environment -> my backend url is https://dev.com
PRO environment -> https://pro.com.
I use Android Studio/Xcode to config build type for each environment (dev/pro) and build into apk/ipa. The problem is I have no idea on how the config for flutter code is relevant to the config in Android Studio/Xcode. What is the right way to solve my problem? Can anyone explain me what I need to do?
This is my config in Android Studio
buildTypes {
release {
signingConfig signingConfigs.release
}
dev {
initWith release
applicationIdSuffix ".dev"
}
pro {
initWith release
}
}
main.dartfiles for different environments, such asmain_dev.dartandmain_pro.dart. 2. Use a method channel. Flutter provides a way to save the environment, and the native code can call this method.