4

Info:

  1. Package: image_picker plugin for flutter, version 0.6.3+1
  2. Android build only, no IOS

Problem:

This is my method to pick an image:

  Future<void> pickImage(ImageSource source) async {
    File selected = await ImagePicker.pickImage(source: source);
    print(selected?.path);
    imageFilePath = selected?.path ?? imageFilePath;
  }

=> When using ImageSource.gallery, when choosing a picture which is not in cache, 'selected.path' prints null. When selecting a picture which is in cache, it does retrieve it, 'selected.path' prints:

/data/user/0/be.etnic.parrainage_mcf/cache/image_picker2517179621202627006.jpg

Anyone knows what causes this problem and how I can solve it?

Sidenotes:

  1. I can also pick an image by making a picture directly with ImageSource.camera, this doesn't give me any problems.
  2. I'm not 100% sure that the selected pictures that return null are not in cache, but the pictures that do return correctly from choosing from the ImageSource.gallery all come from that cache-folder
  3. I don't have any permissions set in my AndroidManifest.xml (other than Internet permission)
SimonartM
  • 668
  • 2
  • 11
  • 26

1 Answers1

3

Based on this link https://github.com/flutter/flutter/issues/41459#issuecomment-563986851, following should solve the problem:

android:requestLegacyExternalStorage="true" 
M--
  • 25,431
  • 8
  • 61
  • 93
mario francois
  • 1,291
  • 1
  • 9
  • 16