Is it possible to get flavor name Flutter side? for both android and ios
build.gradle
flavorDimensions "app"
productFlavors {
dev {
dimension "app"
versionCode 2
versionName "1.0.0"
}
qa {
dimension "app"
applicationId "com.demo.qa"
versionCode 3
versionName "1.0.2"
}
}
As long as every flavor has a different packageName you could do it like this:
enum EnvironmentType { dev, qa }
class Environment {
EnvironmentType current;
Environment() {
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
switch (packageInfo.packageName) {
case "com.demo.qa":
current = EnvironmentType.qa;
break;
default:
current = EnvironmentType.dev;
}
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With