diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index f8eb630970..76b10edf09 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -28,7 +28,10 @@ import '../version.dart'; class CreateCommand extends FlutterCommand { CreateCommand() { - usesPubOption(); + argParser.addFlag('pub', + defaultsTo: true, + help: 'Whether to run "flutter packages get" after the project has been created.' + ); argParser.addFlag( 'with-driver-test', negatable: true, @@ -158,7 +161,7 @@ class CreateCommand extends FlutterCommand { templateContext['description'] = description; generatedCount += _renderTemplate('package', dirPath, templateContext); - if (shouldRunPub) + if (argResults['pub']) await pubGet(context: PubContext.createPackage, directory: dirPath); final String relativePath = fs.path.relative(dirPath); @@ -176,7 +179,7 @@ class CreateCommand extends FlutterCommand { templateContext['description'] = description; generatedCount += _renderTemplate('plugin', dirPath, templateContext); - if (shouldRunPub) + if (argResults['pub']) await pubGet(context: PubContext.createPlugin, directory: dirPath); if (android_sdk.androidSdk != null) @@ -214,7 +217,7 @@ class CreateCommand extends FlutterCommand { previewDart2: false, ); - if (shouldRunPub) { + if (argResults['pub']) { await pubGet(context: PubContext.create, directory: appPath); injectPlugins(directory: appPath); } diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 8723d22233..5d673b61c4 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -362,7 +362,7 @@ abstract class FlutterCommand extends Command { } // Validate the current package map only if we will not be running "pub get" later. - if (parent?.name != 'packages' && !shouldRunPub) { + if (parent?.name != 'packages' && !(_usesPubOption && argResults['pub'])) { final String error = new PackageMap(PackageMap.globalPackagesPath).checkValid(); if (error != null) throw new ToolExit(error);