miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.33k stars 664 forks source link

Flutter web picker does not return after cancel #738

Closed edandaria closed 3 years ago

edandaria commented 3 years ago

In pubspec.yaml: file_picker: '>=3.0.0 <4.0.0' I call the file picker like this: FilePickerResult? _fileResult = await FilePicker.platform.pickFiles( type: FileType.custom, allowedExtensions: [ 'mov', 'mp4', ], withData: true, ); in Flutter web running in Chrome on Ubuntu. [✓] Flutter (Channel beta, 2.2.0, on Linux, locale es_ES.UTF-8)

The open file dialog appears and works perfectly. And if you select a file no problem. But if you click "cancel", the dialog disappears, but the above code does not return.

miguelpruivo commented 3 years ago

Hi, it should return null.

edandaria commented 3 years ago

I tried a minimal app: a button click to call FilePicker and it does return null when you cancel. However the exact same code in my app does not return (ever). I suppose it must be an interaction with another plugin. I will investigate further.

edandaria commented 3 years ago

In case you think of a possible interaction, this is the code fragment I am using: print('FileExplorer: pickFile'); FilePickerResult? _fileResult = await FilePicker.platform.pickFiles( type: FileType.custom, allowedExtensions: extensions, // ['pdf'] withData: true, ); print('FileExplorer: pickFile: result: ' + _fileResult.toString()); and the second print does not happen.

edandaria commented 3 years ago

In case you think of a possible interaction, this is the code fragment I am using: print('FileExplorer: pickFile'); FilePickerResult? _fileResult = await FilePicker.platform.pickFiles( type: FileType.custom, allowedExtensions: extensions, // ['pdf'] withData: true, ); print('FileExplorer: pickFile: result: ' + _fileResult.toString()); and the second print does not happen.

edandaria commented 3 years ago

I thought I had the latest version but no. My problem was that it was broken in 3.0.0 and fixed in 3.0.2+2