Flutter_file_picker: Cancel picking a file and then pick again throws an error and breaks the app

Created on 23 Dec 2018  路  6Comments  路  Source: miguelpruivo/flutter_file_picker

Try to cancel the first request of picking the file and then reopen the file picker. It throws a Platform Exception which, is not being caught in PlatformException

    Future getBrochure() async {
    try {
      await FilePicker.getFilePath(type: FileType.ANY)
          .catchError((error) => print(error))
          .then((brochure_path) {
            print("Completed");
        if (brochure_path != "" || brochure_path != null) {
          print("fired");
          setState(() {
            brochure = File(brochure_path);
          });
        }
      });
    } on PlatformException catch (e) {
      print(e);
    }
  }
awaiting response

Most helpful comment

Released. See changelog

All 6 comments

@pushangupta I've tried to re-create your issue even with your code and I can't seem to be able to replicate. Everything seems to be fine. Would you mind to add some logs?

@miguelpruivo

screen shot 2018-12-27 at 12 08 54 am
screen shot 2018-12-27 at 12 09 15 am

These are logs after running on IOS simulator

@miguelpruivo I think your ios delegate file misses to hit the "canceled by the user" case.
Actually I have narrowed it down.

The problem what I think is, when you cancel choosing the file, the request isn't terminated. So the asynchronous request is still in the memory and when we try to shoot the second request, conflict occurs.

Thank you @pushangupta I've found the issue and it is already solved in the beta. I'm looking to release a new version to dart pub soon with this fixed and also new features such as custom file type filtering (between today and tomorrow).

@miguelpruivo Glad to hear that. I am really looking forward for your release. Keep it up!

Released. See changelog

Was this page helpful?
0 / 5 - 0 ratings

Related issues

repetitions picture repetitions  路  4Comments

ened picture ened  路  7Comments

miguelpruivo picture miguelpruivo  路  7Comments

JAICHANGPARK picture JAICHANGPARK  路  3Comments

ElaineSchwner picture ElaineSchwner  路  4Comments