-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Currently, the app flavor is passed into the FLUTTER_APP_FLAVOR based on the --flavor flag passed into the Flutter tool, as implemented in #134179
flutter/packages/flutter_tools/lib/src/runner/flutter_command.dart
Lines 1341 to 1352 in 9441f9d
| final String? cliFlavor = argParser.options.containsKey('flavor') ? stringArg('flavor') : null; | |
| final String? flavor = cliFlavor ?? defaultFlavor; | |
| if (flavor != null) { | |
| if (globals.platform.environment['FLUTTER_APP_FLAVOR'] != null) { | |
| throwToolExit('FLUTTER_APP_FLAVOR is used by the framework and cannot be set in the environment.'); | |
| } | |
| if (dartDefines.any((String define) => define.startsWith('FLUTTER_APP_FLAVOR'))) { | |
| throwToolExit('FLUTTER_APP_FLAVOR is used by the framework and cannot be ' | |
| 'set using --${FlutterOptions.kDartDefinesOption} or --${FlutterOptions.kDartDefineFromFileOption}'); | |
| } | |
| dartDefines.add('FLUTTER_APP_FLAVOR=$flavor'); | |
| } |
However, that solution doesn't work when run from native tooling, like Android Studio of Xcode, which calls only into flutter assemble, so FLUTTER_APP_FLAVOR is unset.
The proposed community solution at flutter/website#11178 for iOS/macOS requires DART_DEFINES to be individually set per Xcode scheme/config, which would be very easy to get out-of-sync, and essentially unnecessary given that assemble already has all the information it needs to parse which flavor should be used.
It would be better if the flavor parsing logic were pushed down into assemble.