Closed rohitrvayuz closed 3 years ago
Hum. The file_picker is also opened in a modal and the app is kept on background while doing the task of picking. Are you telling me that the image_picker doesn’t do that?
Hum. The file_picker is also opened in a modal and the app is kept on background while doing the task of picking. Are you telling me that the image_picker doesn’t do that?
@miguelpruivo Currently, both document picker and image/gallery picker on iOS are not being opened modally. They open on full screen and put the app in inactive state.
This is the log when I open the picker, select a file and then the picker closes
[log] app is inactive [log] app is paused [log] app is inactive [App Lifecycle] app is resumed 2 [Lifecycle] AppLifecycleState.resumed [Picker result] [/Users/username/Library/Developer/CoreSimulator/Devices/E52232D1-52A3-479D-A247-DC2798F51CAB/data/Containers/Data/Application/4190E9EB-7CB2-4CE0-B295-1CC6E5393215/tmp/com.app-Inbox/sample.pdf] [Picker file] File: '/Users/username/Library/Developer/CoreSimulator/Devices/E52232D1-52A3-479D-A247-DC2798F51CAB/data/Containers/Data/Application/4190E9EB-7CB2-4CE0-B295-1CC6E5393215/tmp/com.app-Inbox/sample.pdf'
@miguelpruivo The image_picker opens the view modally without putting the app in background.
Ok, I'll take a look.
Ok, I'll take a look.
@miguelpruivo Thanks. Or if you could just guide me or tell me a hint where to look at then I can fork the repo and submit the pull request. I have never created packages for flutter before, that's why I am asking
@rohitrvayuz I'm right now looking into it, however, what is the plugin that you're saying that opens modally? Because the image_picker opens it exactly the same way as this one (using UIModalPresentationCurrentContext
presentation).
Nevertheless, I can switch it for a modal.
@rohitrvayuz I'm right now looking into it, however, what is the plugin that you're saying that opens modally? Because the image_picker opens it exactly the same way as this one (using
UIModalPresentationCurrentContext
presentation).Nevertheless, I can switch it for a modal.
You can see here that it's using the UIModalPresentationCurrentContext
which displays the picker in a separate ViewController
, hence, making the app going into background mode — exactly the same behaviour of the file_picker.
I can update it to the desired behaviour, I'm just wondering how can it be since they are both using the same way of presentation when one is clearly using UIModalPresentationFormSheet
.
The document_picker
is using the automatic mode which can result in the modal sheet, yes.
I can update it to the desired behaviour, I'm just wondering how can it be since they are both using the same way of presentation when one is clearly using
UIModalPresentationFormSheet
.
@miguelpruivo Ok. Thanks.
The
document_picker
is using the automatic mode which can result in the modal sheet, yes.
Yes, this is what I want actually. Check this
I'm just surprised of image_picker
displaying that way too, are you sure? Because by the code it doesn't look like it.
Done and published with 4.0.1
. Let me know if it's good for you now. Thank you!
Done and published with
4.0.1
. Let me know if it's good for you now. Thank you!
Thanks a lot @miguelpruivo. It is working as expected now.
Unfortunately this PR will cause the FilePicker to fail and throw an exception if the user just swipes down the modal picker window rather than tapping cancel.
To reproduce :
If you encapsulate your code within a try..catch .. you will see the exception that is raised :
PlatformException: Multiple requests. Cancelled by a second request.
Sample code
FilePickerResult fileResult;
// FilePicker.platform.clearTemporaryFiles();
try {
if (DeviceHelper.isAndroid) {
fileResult = await FilePicker.platform.pickFiles(
type: FileType.any,
);
} else {
fileResult = await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: [
'ttf',
]);
}
} on Exception catch (e) {
DialogHelper.alert(
'File error', 'It was not possible to open the file', context);
return;
}
The only solution if we still want to keep this new way of showing the modal dialog is to always do a :
FilePicker.platform.clearTemporaryFiles();
Prior to showing the dialog but then we loose the benefits of caching.
@MsXam I might have to reset after dismissing. I’ll take a look.
@MsXam I have this also - do you have a fix for this ?
This has now been fixed with 4.1.1. Thank you all.
This seems to be the case on Android still, I'm loading files the same way as listed above and I'm on ^4.2.7. Upon calling pickFiles the AppState goes into paused, and upon returning becomes resumes.
Describe the bug The image picker or the document picker on iOS opens in new window and moves the app to inactive state and upon selecting the file it moves the app back to the resume state. The problem here is that I have a banking app which asks for PIN every time the app is resumed and due to this I am not able to implement the functionality. The default ImagePicker open the gallery modally on iOS but it does not support pdf files therefore I used your file_picker but it does not open the gallery and document picker modally.
Platform
Platform OS version iOS 14.6
How are you picking?
Flutter Version details