pickImageFromGallery method

Future<void> pickImageFromGallery({
  1. CompoundSelector? imageSelector,
  2. int? index,
  3. Duration? timeout,
})

Pick an image from the gallery

This method opens the gallery and selects a single image.

You can provide a custom selector for the image using imageSelector. If no custom selector is provided, default selectors will be used. Alternatively, you can specify an index to select the nth image when using default selectors.

Note: If you provide imageSelector, the index parameter will be overwritten.

Implementation

Future<void> pickImageFromGallery({
  CompoundSelector? imageSelector,
  int? index,
  Duration? timeout,
}) {
  return platform.action.mobile(
    android: () => platform.android.pickImageFromGallery(
      imageSelector: imageSelector?.android,
      index: index,
      timeout: timeout,
    ),
    ios: () => platform.ios.pickImageFromGallery(
      imageSelector: imageSelector?.ios,
      index: index,
      timeout: timeout,
    ),
  );
}