stopVideoRecording method Null safety

Future<XFile> stopVideoRecording()

Stops the video recording and returns the file where it was saved.

Throws a CameraException if the capture failed.

Implementation

Future<XFile> stopVideoRecording() async {
  _throwIfNotInitialized('stopVideoRecording');
  if (!value.isRecordingVideo) {
    throw CameraException(
      'No video is recording',
      'stopVideoRecording was called when no video is recording.',
    );
  }
  try {
    final XFile file =
        await CameraPlatform.instance.stopVideoRecording(_cameraId);
    value = value.copyWith(
      isRecordingVideo: false,
      recordingOrientation: const Optional<DeviceOrientation>.absent(),
    );
    return file;
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}