Merge pull request #2080 from chinmaygarde/master
Update status messages when unsupported devices are detected by the tools
This commit is contained in:
@@ -30,10 +30,8 @@ class DevicesCommand extends FlutterCommand {
|
||||
printStatus('${devices.length} connected ${pluralize('device', devices.length)}:');
|
||||
|
||||
for (Device device in devices) {
|
||||
printStatus('\t${_supportIndicator(device)}: ${device.name} (${device.id})');
|
||||
if (!device.isSupported()) {
|
||||
printStatus("\t\t${device.supportMessage()}");
|
||||
}
|
||||
String supportIndicator = device.isSupported() ? '' : '- unsupported';
|
||||
printStatus('${device.name} (${device.id}) ${supportIndicator}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +39,4 @@ class DevicesCommand extends FlutterCommand {
|
||||
}
|
||||
}
|
||||
|
||||
String _supportIndicator(Device device) => device.isSupported() ? "[✔] Supported" : "[✘] Unsupported";
|
||||
|
||||
String pluralize(String word, int count) => count == 1 ? word : word + 's';
|
||||
|
||||
@@ -17,6 +17,7 @@ import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../toolchain.dart';
|
||||
import 'apk.dart';
|
||||
import 'devices.dart';
|
||||
import 'install.dart';
|
||||
import 'stop.dart';
|
||||
|
||||
@@ -173,6 +174,7 @@ Future<int> startApp(
|
||||
}
|
||||
|
||||
bool startedSomething = false;
|
||||
int unsupportedCount = 0;
|
||||
|
||||
for (Device device in devices.all) {
|
||||
ApplicationPackage package = applicationPackages.getPackageForPlatform(device.platform);
|
||||
@@ -180,7 +182,8 @@ Future<int> startApp(
|
||||
continue;
|
||||
|
||||
if (!device.isSupported()) {
|
||||
printStatus("Skipping unsupported device: ${device.name}");
|
||||
printStatus("Skipping unsupported device '${device.name}'. ${device.supportMessage()}");
|
||||
unsupportedCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -220,7 +223,14 @@ Future<int> startApp(
|
||||
}
|
||||
|
||||
if (!startedSomething) {
|
||||
printError('Unable to run application. Please ensure that a supported device/simulator is connected.');
|
||||
int connected = devices.all.where((device) => device.isConnected()).length;
|
||||
String message = 'Unable to run application';
|
||||
if (connected == 0) {
|
||||
message += ' - no connected devices.';
|
||||
} else if (unsupportedCount != 0) {
|
||||
message += ' - $unsupportedCount unsupported ${pluralize('device', unsupportedCount)} connected';
|
||||
}
|
||||
printError(message);
|
||||
}
|
||||
|
||||
return startedSomething ? 0 : 2;
|
||||
|
||||
Reference in New Issue
Block a user