plugins
plugins copied to clipboard
[webview_flutter] Add file upload on Android
Currently on Android nothing happens for <input type="file">
This PR solves that by registering the callback onShowFileChooser
on the WebView
that must returns a Future<List<String>>
(list of file path).
It lets you use which-ever file-provider plugin you want to use as recommended by @stuartmorgan here.
Status:
- [X] Tried it with [image_provider] and it's working
- [ ] Before diving into tests, I hope to have feedbacks on the implementation.
- [ ] Need to read all Contributor guides
Thanks all
Related issues
#3225 https://github.com/flutter/flutter/issues/27924
Pre-launch Checklist
- [ ] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use
dart format
.) - [ ] I signed the CLA.
- [X] The title of the PR starts with the name of the plugin surrounded by square brackets, e.g.
[shared_preferences]
- [X] I listed at least one issue that this PR fixes in the description above.
- [ ] I updated
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes. - [ ] I updated
CHANGELOG.md
to add a description of the change, following repository CHANGELOG style. - [ ] I updated/added relevant documentation (doc comments with
///
). - [ ] I added new tests to check the change I am making, or this PR is test-exempt.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).
If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?
Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
For more information, open the CLA check for this pull request.
@dupuchba Are you interested in following-up with the narrower scope @bparrishMines suggested above?
@dupuchba Are you interested in following-up with the narrower scope @bparrishMines suggested above?
Yes I am, I was thinking at adding this when @bparrishMines work would be ready :-) !
Hi @dupuchba I had a good working WebView (webview_flutter: ^2.0.4) and I had implemented file upload as well (based on https://github.com/flutter/plugins/pull/3225), but after I updated to API version 31, I got the whole new architecture and the whole file upload issue is broken and without knowing that this happened I have released the new app version to public.
I need a way out ASAP. Could you guide me where do I make the change? I am all confused looking at the new arch.
[UPDATE]: I made the changes to the package based on your changes and still it doesn't work.
hey @Shubhankt1 I am going on holidays and I don't have the time to get back at this issue. Last April I said I would make a PR with the new plugin architecture for flutter_webview, once it's done. If you want to make it work it's pretty straightforward, plus you have my PR as an example. Basically I just wrote some platform code for this method https://developer.android.com/reference/android/webkit/WebChromeClient.html#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback%3Candroid.net.Uri[]%3E,%20android.webkit.WebChromeClient.FileChooserParams)
Status update from triage: Still blocked on https://github.com/flutter/flutter/issues/94051, but we hope to have that resolved soon.
Isn't it frustrating that if this a solution, it cannot be merged for everyone to use?
@godilite to be faire I've not updated my commit to the new platform infrastructure. And I personally don't think it's frustrating, you can still contribute and make it a reality !
Hi.
I am happy to see https://github.com/flutter/flutter/issues/94051 merged which was blocking this.
Now, is there a timeframe for when this will be closed? I am holding an update to my app based on your comments.
thanks and best.
@rashidotm excellent news ! I am probably going to address this in January 23
@dupuchba Thanks for your contribution and patience! I had time to work on this, so I went ahead and created https://github.com/flutter/plugins/pull/6881, that uses the new infrastructure of the plugin. I'm going to go ahead and close this one in favor of the other.
@bparrishMines thanks a lot for your time and work.
For what it's worth, it was still on my daily reminder (but I kept pushing it) ^^