availableCameras function

Future<List<CameraDescription>> availableCameras()

Completes with a list of available cameras.

May throw a CameraException.

Implementation

Future<List<CameraDescription>> availableCameras() async {
  try {

    List<Map<dynamic, dynamic>> cameras = (await _channel.invokeListMethod<Map<dynamic, dynamic>>('availableCameras'))!;
    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);
  }
}