pickImage method

  1. @override
Future<PickedFile> pickImage({
  1. required ImageSource source,
  2. double? maxWidth,
  3. double? maxHeight,
  4. int? imageQuality,
  5. CameraDevice preferredCameraDevice = CameraDevice.rear,
})

Returns a PickedFile with the image that was picked.

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

Note that the maxWidth, maxHeight and imageQuality arguments are not supported on the web. If any of these arguments 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<PickedFile> pickImage({
  required ImageSource source,
  double? maxWidth,
  double? maxHeight,
  int? imageQuality,
  CameraDevice preferredCameraDevice = CameraDevice.rear,
}) {
  String? capture = computeCaptureAttribute(source, preferredCameraDevice);
  return pickFile(accept: _kAcceptImageMimeType, capture: capture);
}