[tools] Add column header for emulators information (#142853)

Add column information as table header for `flutter emulators` command.

**Before:**

```
2 available emulators:

Pixel_3_API_30   • Pixel 3 API 30   • Google • android
Resizable_API_33 • Resizable API 33 • Google • android

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
```

**After:**

```
2 available emulators:

Id               • Name             • Manufacturer • Platform

Pixel_3_API_30   • Pixel 3 API 30   • Google       • android
Resizable_API_33 • Resizable API 33 • Google       • android

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
```

fixes #140656
This commit is contained in:
Anas
2024-02-14 18:19:24 +05:30
committed by GitHub
parent abadf9ff8c
commit ca03beda4d
2 changed files with 24 additions and 1 deletions

View File

@@ -291,8 +291,16 @@ abstract class Emulator {
return <String>[];
}
const List<String> tableHeader = <String>[
'Id',
'Name',
'Manufacturer',
'Platform',
];
// Extract emulators information
final List<List<String>> table = <List<String>>[
tableHeader,
for (final Emulator emulator in emulators)
<String>[
emulator.id,
@@ -323,7 +331,10 @@ abstract class Emulator {
}
static void printEmulators(List<Emulator> emulators, Logger logger) {
descriptions(emulators).forEach(logger.printStatus);
final List<String> emulatorDescriptions = descriptions(emulators);
// Prints the first description as the table header, followed by a newline.
logger.printStatus('${emulatorDescriptions.first}\n');
emulatorDescriptions.sublist(1).forEach(logger.printStatus);
}
}