Implementation
Future<List<Disk>> get query async {
if (Platform.isLinux) {
final result = await _lsblk.query;
final json = jsonDecode(result);
return (json['blockdevices'] as List)
.map((disk) => Disk.fromLsblk(disk as Map<String, dynamic>))
.where(
(disk) =>
!disk.device.startsWith('/dev/loop') &&
!disk.device.startsWith('/dev/sr') &&
!disk.device.startsWith('/dev/ram'),
)
.toList(growable: false);
} else if (Platform.isMacOS || Platform.isWindows) {
final results = await _channel.invokeListMethod('query');
return results
?.map((result) => Disk.fromMap(Map.from(result)))
.toList(growable: false) ??
[];
}
throw UnsupportedPlatformException(Platform.operatingSystem);
}