availableCameras method
Completes with a list of available cameras.
This method returns an empty list when no cameras are available.
Implementation
@override
Future<List<CameraDescription>> availableCameras() async {
try {
final List<String?> cameras = await _hostApi.getAvailableCameras();
return cameras.map((String? cameraName) {
return CameraDescription(
// This type is only nullable due to Pigeon limitations, see
// https://github.com/flutter/flutter/issues/97848. The native code
// will never return null.
name: cameraName!,
// TODO(stuartmorgan): Implement these; see
// https://github.com/flutter/flutter/issues/97540.
lensDirection: CameraLensDirection.front,
sensorOrientation: 0,
);
}).toList();
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}