availableCameras function
Completes with a list of available cameras.
May throw a CameraException.
Implementation
Future<List<CameraDescription>> availableCameras() async {
try {
final List<Map<dynamic, dynamic>> cameras = await (_channel
.invokeListMethod<Map<dynamic, dynamic>>('availableCameras') as FutureOr<List<Map<dynamic, dynamic>>>);
return cameras.map((Map<dynamic, dynamic> camera) {
return CameraDescription(
name: camera['name'],
lensDirection: parseCameraLensDirection(camera['lensFacing']),
sensorOrientation: camera['sensorOrientation'],
);
}).toList();
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}