switchCamera method

Future<void> switchCamera(
  1. String cameraId
)

switch CameracameraId`.

This switch Camera to the camera with the given cameraId.

Throws a CameraException if the capture fails.

Implementation

Future<void> switchCamera(String cameraId) async {
  if (!value.isInitialized! || _isDisposed) {
    throw CameraException(
      'Uninitialized CameraController',
      'startVideoStreaming was called on uninitialized CameraController',
    );
  }
  if (!value.isStreamingVideoRtmp!) {
    throw CameraException(
      'No video is recording',
      'resumeVideoStreaming was called when no video is streaming.',
    );
  }
  if(!Platform.isAndroid){
    throw CameraException(
      'Currently only supports Android platform',
      'Please use on Android platform',
    );
  }

  try {
    await _channel
        .invokeMethod<void>('switchCamera', <String, dynamic>{
      'cameraId': cameraId
    });
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}