getVideo method

  1. @override
Future<XFile> getVideo({
  1. required ImageSource source,
  2. CameraDevice preferredCameraDevice = CameraDevice.rear,
  3. Duration? maxDuration,
})

Returns an XFile containing the video that was picked.

The source argument controls where the video comes from. This can be either ImageSource.camera or ImageSource.gallery.

Note that the maxDuration argument is not supported on the web. If the argument is supplied, it'll be silently ignored by the web version of the plugin.

Use preferredCameraDevice to specify the camera to use when the source is ImageSource.camera. The preferredCameraDevice is ignored when source is ImageSource.gallery. It is also ignored if the chosen camera is not supported on the device. Defaults to CameraDevice.rear.

If no images were picked, the return value is null.

Implementation

@override
Future<XFile> getVideo({
  required ImageSource source,
  CameraDevice preferredCameraDevice = CameraDevice.rear,
  Duration? maxDuration,
}) async {
  String? capture = computeCaptureAttribute(source, preferredCameraDevice);
  List<XFile> files = await getFiles(
    accept: _kAcceptVideoMimeType,
    capture: capture,
  );
  return files.first;
}