- Notifications
You must be signed in to change notification settings - Fork832
IOS Safari File Picker Fixed#1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- Removed unnecessary import of `html/parser.dart`.- Removed the `_ensureInitialized` function and the related `_kFilePickerInputsDomId`.- Removed the private variable `_target`.- Refactored code to remove parsing of HTML string into document object.- Added a check for null in `_addFileToResult`- added a null check if the file attribute is not null.- Added a null check for the files attribute in the `pickFiles` function.- improved conditional statement for checking isSafariIos
The confirmation modal's styles have been updated to more closely match the style of iOS dialogs. This includes changes to the modal's positioning, background color, borders, shadows, and overall width. The content container, title, detail text, and button container have all been adjusted to improve visual consistency and alignment. Button styles for the "Cancel" and "Allow" actions have also been refined. Added "Don't Allow" and "Allow" text to the buttons.
navaronbracke commentedMar 19, 2025
This feels more like a workaround, rather than an actual fix? Instead of using a fake dialog, I would look into using a more long term solution. |
navaronbracke commentedMar 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Maybe a long term solution is just to have the input element invisible? (instead of The input element is doing that here:https://github.com/miguelpruivo/flutter_file_picker/blob/master/lib/_internal/file_picker_web.dart#L67 Seehttps://stackoverflow.com/questions/26501221/calling-click-event-of-input-doesnt-work-in-safari |
ishaquehassan commentedMar 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think we can calculate the element position where file picker is placed and then overlay the input element there. |
Uh oh!
There was an error while loading.Please reload this page.
PR: Fix iOS Safari File Picker Issue with a Transparent Overlay
Summary
This PR resolves an iOS Safari limitation where a programmatic click (
.click()) on an<input type="file">is blocked. Instead of relying on a virtual click, this solution uses a custom dialog with a transparent, overlaid<input type="file">element on the “Allow” button to ensure iOS recognizes it as a genuine user interaction.Background
.click()triggers for file inputs are prevented for security reasons.Approach
<input type="file">withopacity: 0on top of the "Allow" button.Implementation Details
position: absolute; opacity: 0;).Testing
Screenshot
See the attached screenshot showing the dialog with the “Allow” button and the transparent file input overlay.

By merging this PR, we ensure a consistent, user-friendly file upload experience on iOS Safari, aligning with the direct interaction requirement.