Search code examples
iosflutterdart

Flutter file explorer not working with file_picker


Sorry, i'm a newbie to flutter.
I've created a Button, it should run the following function (as i thought, this should also open the file explorer) but it doesn't work. The Button is there, but nothing more is happening if its pressed.


  Padding newPadding() {
    return new Padding(
      padding: const EdgeInsets.only(top: 50.0, bottom: 20.0),
        child: ElevatedButton(
          onPressed:_openFileExplorer,
          child: const Text("Open File picker"),
                ),
              );
  }

FilePickerResult? result = await FilePicker.platform.pickFiles();

    if (result != null) {
      PlatformFile file = result.files.first;
      print(file.path);
    }    
    else {
  // User canceled the picker
  } 
}


What have i forgot?


Solution

  • In IOS add the following steps in POD file.

    Add the below line on project root/ios/Podfile before the line target 'Runner' do.

    Pod::PICKER_MEDIA = false, resp. Pod::PICKER_AUDIO = false, resp. Pod::PICKER_DOCUMENT = false
    

    #Additional note

    resp. is not iOS POD syntax, its abbreviation. to respective; or respectively.

    After added, the code should look like this:

    Pod::PICKER_MEDIA = false
    Pod::PICKER_AUDIO = false
    Pod::PICKER_DOCUMENT = false
    target 'Runner' do
      use_frameworks!
      use_modular_headers!