Flatten descriptions from Stream to List

This commit is contained in:
Danny Tuppeny
2018-04-19 09:01:59 +01:00
committed by Danny Tuppeny
parent b5a3d26f75
commit 76815faeac
2 changed files with 10 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ class EmulatorsCommand extends FlutterCommand {
} else {
printStatus(
'${emulators.length} available ${pluralize('emulator', emulators.length)}:\n');
await Emulator.printEmulators(emulators);
Emulator.printEmulators(emulators);
}
}
}

View File

@@ -102,9 +102,9 @@ abstract class Emulator {
@override
String toString() => name;
static Stream<String> descriptions(List<Emulator> emulators) async* {
static List<String> descriptions(List<Emulator> emulators) {
if (emulators.isEmpty)
return;
return <String>[];
// Extract emulators information
final List<List<String>> table = <List<String>>[];
@@ -125,12 +125,14 @@ abstract class Emulator {
}
// Join columns into lines of text
for (List<String> row in table) {
yield indices.map((int i) => row[i].padRight(widths[i])).join(' • ') + ' • ${row.last}';
}
return table.map((List<String> row) {
return indices
.map((int i) => row[i].padRight(widths[i]))
.join(' • ') + ' • ${row.last}';
}).toList();
}
static Future<Null> printEmulators(List<Emulator> emulators) async {
await descriptions(emulators).forEach(printStatus);
static void printEmulators(List<Emulator> emulators) {
descriptions(emulators).forEach(printStatus);
}
}