Closed edandaria closed 3 years ago
Hi, it should return null
.
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.
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.
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.
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
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.