Do not check for an existing package map if a command is going to run "pub get" to update the package map (#3202)
Also remove a redundant check for the --pub option in the run command
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart
index 88ddcb7..e78f11c 100644
--- a/packages/flutter_tools/lib/src/commands/run.dart
+++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -10,7 +10,6 @@
import '../application_package.dart';
import '../base/common.dart';
import '../build_configuration.dart';
-import '../dart/pub.dart';
import '../device.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
@@ -83,16 +82,6 @@
bool get requiresDevice => true;
@override
- Future<int> run() async {
- if (argResults['pub']) {
- int exitCode = await pubGet();
- if (exitCode != 0)
- return exitCode;
- }
- return await super.run();
- }
-
- @override
Future<int> runInProject() async {
bool clearLogs = argResults['clear-logs'];
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index 876c832..73bc0c4 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -154,10 +154,13 @@
}
}
- String error = PackageMap.instance.checkValid();
- if (error != null) {
- printError(error);
- return false;
+ // Validate the current package map only if we will not be running "pub get" later.
+ if (!(_usesPubOption && argResults['pub'])) {
+ String error = PackageMap.instance.checkValid();
+ if (error != null) {
+ printError(error);
+ return false;
+ }
}
return true;