@@ -168,48 +168,43 @@ class DevicesCommandOutput {
168
168
}
169
169
170
170
if (allDevices.isEmpty) {
171
- _printNoDevicesDetected ( );
171
+ _logger. printStatus ( 'No authorized devices detected.' );
172
172
} else {
173
173
if (attachedDevices.isNotEmpty) {
174
- _logger.printStatus ('${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:\n ' );
175
- await Device .printDevices (attachedDevices, _logger);
174
+ _logger.printStatus ('Found ${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:' );
175
+ await Device .printDevices (attachedDevices, _logger, prefix : ' ' );
176
176
}
177
177
if (wirelessDevices.isNotEmpty) {
178
178
if (attachedDevices.isNotEmpty) {
179
179
_logger.printStatus ('' );
180
180
}
181
- _logger.printStatus ('${wirelessDevices .length } wirelessly connected ${pluralize ('device' , wirelessDevices .length )}:\n ' );
182
- await Device .printDevices (wirelessDevices, _logger);
181
+ _logger.printStatus ('Found ${wirelessDevices .length } wirelessly connected ${pluralize ('device' , wirelessDevices .length )}:' );
182
+ await Device .printDevices (wirelessDevices, _logger, prefix : ' ' );
183
183
}
184
184
}
185
- await _printDiagnostics ();
185
+ await _printDiagnostics (foundAny : allDevices.isNotEmpty );
186
186
}
187
187
188
- void _printNoDevicesDetected () {
189
- final StringBuffer status = StringBuffer ('No devices detected.' );
190
- status.writeln ();
188
+ Future <void > _printDiagnostics ({ required bool foundAny }) async {
189
+ final StringBuffer status = StringBuffer ();
191
190
status.writeln ();
191
+ final List <String > diagnostics = await _deviceManager? .getDeviceDiagnostics () ?? < String > [];
192
+ if (diagnostics.isNotEmpty) {
193
+ for (final String diagnostic in diagnostics) {
194
+ status.writeln (diagnostic);
195
+ status.writeln ();
196
+ }
197
+ }
192
198
status.writeln ('Run "flutter emulators" to list and start any available device emulators.' );
193
199
status.writeln ();
194
- status.write ('If you expected your device to be detected, please run "flutter doctor" to diagnose potential issues. ' );
200
+ status.write ('If you expected ${ foundAny ? 'another' : 'a' } device to be detected, please run "flutter doctor" to diagnose potential issues. ' );
195
201
if (deviceDiscoveryTimeout == null ) {
196
- status.write ('You may also try increasing the time to wait for connected devices with the --${FlutterOptions .kDeviceTimeout } flag. ' );
202
+ status.write ('You may also try increasing the time to wait for connected devices with the " --${FlutterOptions .kDeviceTimeout }" flag. ' );
197
203
}
198
204
status.write ('Visit https://flutter.dev/setup/ for troubleshooting tips.' );
199
-
200
205
_logger.printStatus (status.toString ());
201
206
}
202
207
203
- Future <void > _printDiagnostics () async {
204
- final List <String > diagnostics = await _deviceManager? .getDeviceDiagnostics () ?? < String > [];
205
- if (diagnostics.isNotEmpty) {
206
- _logger.printStatus ('' );
207
- for (final String diagnostic in diagnostics) {
208
- _logger.printStatus ('• $diagnostic ' , hangingIndent: 2 );
209
- }
210
- }
211
- }
212
-
213
208
Future <void > printDevicesAsJson (List <Device > devices) async {
214
209
_logger.printStatus (
215
210
const JsonEncoder .withIndent (' ' ).convert (
@@ -266,8 +261,8 @@ class DevicesCommandOutputWithExtendedWirelessDeviceDiscovery extends DevicesCom
266
261
267
262
// Display list of attached devices.
268
263
if (attachedDevices.isNotEmpty) {
269
- _logger.printStatus ('${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:\n ' );
270
- await Device .printDevices (attachedDevices, _logger);
264
+ _logger.printStatus ('Found ${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:' );
265
+ await Device .printDevices (attachedDevices, _logger, prefix : ' ' );
271
266
_logger.printStatus ('' );
272
267
numLinesToClear += 1 ;
273
268
}
@@ -292,8 +287,8 @@ class DevicesCommandOutputWithExtendedWirelessDeviceDiscovery extends DevicesCom
292
287
if (_logger.isVerbose && _includeAttachedDevices) {
293
288
// Reprint the attach devices.
294
289
if (attachedDevices.isNotEmpty) {
295
- _logger.printStatus ('\n ${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:\n ' );
296
- await Device .printDevices (attachedDevices, _logger);
290
+ _logger.printStatus ('\n Found ${attachedDevices .length } connected ${pluralize ('device' , attachedDevices .length )}:' );
291
+ await Device .printDevices (attachedDevices, _logger, prefix : ' ' );
297
292
}
298
293
} else if (terminal.supportsColor && terminal is AnsiTerminal ) {
299
294
_logger.printStatus (
@@ -309,16 +304,16 @@ class DevicesCommandOutputWithExtendedWirelessDeviceDiscovery extends DevicesCom
309
304
if (wirelessDevices.isEmpty) {
310
305
if (attachedDevices.isEmpty) {
311
306
// No wireless or attached devices were found.
312
- _printNoDevicesDetected ( );
307
+ _logger. printStatus ( 'No authorized devices detected.' );
313
308
} else {
314
309
// Attached devices found, wireless devices not found.
315
310
_logger.printStatus (_noWirelessDevicesFoundMessage);
316
311
}
317
312
} else {
318
313
// Display list of wireless devices.
319
- _logger.printStatus ('${wirelessDevices .length } wirelessly connected ${pluralize ('device' , wirelessDevices .length )}:\n ' );
320
- await Device .printDevices (wirelessDevices, _logger);
314
+ _logger.printStatus ('Found ${wirelessDevices .length } wirelessly connected ${pluralize ('device' , wirelessDevices .length )}:' );
315
+ await Device .printDevices (wirelessDevices, _logger, prefix : ' ' );
321
316
}
322
- await _printDiagnostics ();
317
+ await _printDiagnostics (foundAny : wirelessDevices.isNotEmpty || attachedDevices.isNotEmpty );
323
318
}
324
319
}
0 commit comments