gpt4 book ai didi

flutter - 如何在Flutter上获得 flavor 名称?

转载 作者:行者123 更新时间:2023-12-03 03:08:42 25 4
gpt4 key购买 nike

有可能获得 flavor 名称Flutter side吗?适用于android和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"
}
}

最佳答案

只要每种口味都有不同的packageName,您就可以这样进行:

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;
}
});
}
}

关于flutter - 如何在Flutter上获得 flavor 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60610270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com