Unverified Commit e54e53c1 authored by Stanislav Baranov's avatar Stanislav Baranov Committed by GitHub

Better error messages for flutter tool --dynamic flag. (#26107)

parent 4b474d61
...@@ -237,8 +237,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -237,8 +237,7 @@ abstract class FlutterCommand extends Command<void> {
argParser.addFlag('dynamic', argParser.addFlag('dynamic',
hide: !verboseHelp, hide: !verboseHelp,
negatable: false, negatable: false,
help: 'Enable dynamic code. This flag is intended for use with\n' help: 'Enable dynamic code. Only allowed with --release or --profile.');
'--release or --profile; --debug always has this enabled.');
} }
void addDynamicModeFlags({bool verboseHelp = false}) { void addDynamicModeFlags({bool verboseHelp = false}) {
...@@ -328,12 +327,24 @@ abstract class FlutterCommand extends Command<void> { ...@@ -328,12 +327,24 @@ abstract class FlutterCommand extends Command<void> {
final bool dynamicFlag = argParser.options.containsKey('dynamic') final bool dynamicFlag = argParser.options.containsKey('dynamic')
? argResults['dynamic'] ? argResults['dynamic']
: false; : false;
if (argResults['debug'])
if (argResults['debug']) {
if (dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
return BuildMode.debug; return BuildMode.debug;
}
if (argResults['profile']) if (argResults['profile'])
return dynamicFlag ? BuildMode.dynamicProfile : BuildMode.profile; return dynamicFlag ? BuildMode.dynamicProfile : BuildMode.profile;
if (argResults['release']) if (argResults['release'])
return dynamicFlag ? BuildMode.dynamicRelease : BuildMode.release; return dynamicFlag ? BuildMode.dynamicRelease : BuildMode.release;
if (_defaultBuildMode == BuildMode.debug && dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
if (_defaultBuildMode == BuildMode.release && dynamicFlag)
return BuildMode.dynamicRelease;
if (_defaultBuildMode == BuildMode.profile && dynamicFlag)
return BuildMode.dynamicProfile;
return _defaultBuildMode; return _defaultBuildMode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment