3

I'm trying to pick image from gallery and it works fine. But if the image's extension is webp it's not picking it. So I can't handle the error. Cause it's not throws an error about it. Here is my code snippet:

try {
  final XFile? image = await _picker.pickImage(
      source: ImageSource.gallery);
  if (image != null) {
    print(image.path);
  }
} catch (e) {
  print(e);
}

How can I handle the unsupported image format immediately? I tried timeOut but it also throws error when user viewing the gallery view and not selected image yet.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
bsgal
  • 313
  • 2
  • 13

2 Answers2

0

Try using File Picker instead:

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Diwyansh
  • 2,961
  • 1
  • 7
  • 11
0

It was due to the image format (webp). After 0.8.4+10 version it fixed.

bsgal
  • 313
  • 2
  • 13