pickVideo method

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

Returns an XFile object wrapping the video that was picked.

The returned XFile is intended to be used within a single app session. Do not save the file path and use it across sessions.

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

The maxDuration argument specifies the maximum duration of the captured video. If no maxDuration is specified, the maximum duration will be infinite.

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.

In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost in this call. You can then call retrieveLostData when your app relaunches to retrieve the lost data.

The method could throw PlatformException if the app does not have permission to access the camera or photos gallery, no camera is available, plugin is already in use, temporary file could not be created and video could not be cached (iOS only), plugin activity could not be allocated (Android only) or due to an unknown error.

Implementation

Future<XFile?> pickVideo({
  required ImageSource source,
  CameraDevice preferredCameraDevice = CameraDevice.rear,
  Duration? maxDuration,
}) {
  return platform.getVideo(
    source: source,
    preferredCameraDevice: preferredCameraDevice,
    maxDuration: maxDuration,
  );
}