startVideoCapturing method Null safety

  1. @override
Future<void> startVideoCapturing(
  1. VideoCaptureOptions options

Starts a video recording and/or streaming session.

Please see VideoCaptureOptions for documentation on the configuration options.


Future<void> startVideoCapturing(VideoCaptureOptions options) {
  if (options.streamCallback != null || options.streamOptions != null) {
    throw UnimplementedError('Streaming is not currently supported on web');

  try {
    final Camera camera = getCamera(options.cameraId);

    // Add camera's video recording errors to the camera events stream.
    // The error event fires when the video recording is not allowed or an unsupported
    // codec is used.
    _cameraVideoRecordingErrorSubscriptions[options.cameraId] =
        camera.onVideoRecordingError.listen((html.ErrorEvent errorEvent) {
          'Error code: ${errorEvent.type}, error message: ${errorEvent.message}.',

    return camera.startVideoRecording(maxVideoDuration: options.maxDuration);
  } on html.DomException catch (e) {
    throw PlatformException(code:, message: e.message);
  } on CameraWebException catch (e) {
    throw PlatformException(code: e.code.toString(), message: e.description);