mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Suggest simulator when no devices (#5770)
When flutter run is used on a Mac and no devices are specified or attached, suggest launching a simulator first. Fixes https://github.com/flutter/flutter/issues/5674
This commit is contained in:
parent
5bc8888e7d
commit
bb0a6757fc
@ -13,6 +13,7 @@ import '../cache.dart';
|
||||
import '../device.dart';
|
||||
import '../globals.dart';
|
||||
import '../hot.dart';
|
||||
import '../ios/mac.dart';
|
||||
import '../vmservice.dart';
|
||||
import '../resident_runner.dart';
|
||||
import '../run.dart';
|
||||
@ -98,6 +99,18 @@ class RunCommand extends RunCommandBase {
|
||||
return '$command/${getNameForTargetPlatform(device.platform)}';
|
||||
}
|
||||
|
||||
@override
|
||||
void printNoConnectedDevices() {
|
||||
super.printNoConnectedDevices();
|
||||
if (getCurrentHostPlatform() == HostPlatform.darwin_x64 &&
|
||||
XCode.instance.isInstalledAndMeetsVersionCheck) {
|
||||
printStatus('');
|
||||
printStatus('To run on a simulator, launch it first:');
|
||||
printStatus('open -a Simulator.app');
|
||||
printStatus('');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> runInProject() async {
|
||||
int debugPort;
|
||||
|
||||
@ -141,7 +141,7 @@ abstract class FlutterCommand extends Command {
|
||||
"matching '${deviceManager.specifiedDeviceId}'");
|
||||
return 1;
|
||||
} else if (devices.isEmpty) {
|
||||
printStatus('No connected devices.');
|
||||
printNoConnectedDevices();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -192,6 +192,10 @@ abstract class FlutterCommand extends Command {
|
||||
return await runInProject();
|
||||
}
|
||||
|
||||
void printNoConnectedDevices() {
|
||||
printStatus('No connected devices.');
|
||||
}
|
||||
|
||||
// This is a field so that you can modify the value for testing.
|
||||
Validator commandValidator;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user