listAvailableDevices function
Implementation
Future<List<String>> listAvailableDevices() async {
final result = await runAvdManager(['list', 'device']);
if (result.exitCode != 0) {
print('❌ Failed to list devices');
return [];
}
final devices = <String>[];
final regex = RegExp(r'id: \d+ or "(.*?)"');
for (final line in result.stdout.toString().split('\n')) {
final match = regex.firstMatch(line);
if (match != null) {
devices.add(match.group(1)!);
}
}
if (devices.isEmpty) {
print('⚠️ No devices found.');
return [];
}
return devices;
}