listDevices method
Call this method to discover all camera devices.
Implementation
@override
Future<List<CameraMacOSDevice>> listDevices(
{CameraMacOSDeviceType? deviceType}) async {
try {
final Map<String, dynamic>? args =
await methodChannel.invokeMapMethod<String, dynamic>(
'listDevices',
{
"deviceType": deviceType?.index,
},
);
if (args == null || args["devices"] == null) {
throw FlutterError("Invalid args: invalid platform response");
}
List<Map<String, dynamic>> devicesList = List.from(args["devices"] ?? [])
.map((e) => Map<String, dynamic>.from(e))
.toList();
List<CameraMacOSDevice> devices = [];
for (Map<String, dynamic> m in devicesList) {
CameraMacOSDevice device = CameraMacOSDevice.fromMap(m);
devices.add(device);
}
return devices;
} catch (e) {
return Future.error(e);
}
}