| 123456789101112131415161718192021 |
- /// Flavor 环境标识
- /// 通过 --dart-define=FLAVOR=dev|staging|prod 注入
- enum Flavor { dev, staging, prod }
- abstract class FlavorConfig {
- static const _raw = String.fromEnvironment('FLAVOR', defaultValue: 'dev');
- static Flavor get current {
- return switch (_raw) {
- 'prod' => Flavor.prod,
- 'staging' => Flavor.staging,
- _ => Flavor.dev,
- };
- }
- static bool get isDev => current == Flavor.dev;
- static bool get isStaging => current == Flavor.staging;
- static bool get isProd => current == Flavor.prod;
- static String get name => _raw;
- }
|