promptForDevice function
Implementation
Future<String?> promptForDevice(List<String> devices) async {
print('\nš± Available Devices:\n');
for (int i = 0; i < devices.length; i++) {
print(' [${i + 1}] ${devices[i]}');
}
stdout.write('\nEnter device number: ');
final input = stdin.readLineSync();
final index = int.tryParse(input ?? '');
if (index != null && index > 0 && index <= devices.length) {
return devices[index - 1];
}
print('ā Invalid selection.');
return null;
}