-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter_android] Adds support for receiving Java callback WebChromeClient.onShowFileChooser
#6881
Conversation
WebChromeClient.onShowFileChooser
I thought the decision from the previous discussion of option was that we would start with not providing a default, and suggest that people use |
I assume this PR will obsolete #5172? |
Thank you both for your work 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of questions, but overall LGTM!
Once file_selector_android
lands we should consider updating the example app for this package to show using it to handle this callback.
fileChooserParams, | ||
reply -> { | ||
// The returned list of file paths can only be passed to `filePathCallback` if the | ||
// `onShowFileChooser` method returned true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just not call flutterApi.onShowFileChooser
in the first place if this is true? Or is the idea that you could in theory want to know when it's called (on the Dart side) without actually handling it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I assumed there could be a situation where someone could want to know when a user clicks on the <input name="userfile" type="file">
button. I don't think it hurts to keep it this way.
) { | ||
assert( | ||
!value || onShowFileChooser != null, | ||
'Setting this to true requires `onShowFileChooser` to be nonnull.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert
is debug-only; this should probably be a StateError
.
Thanks for the effort. I am looking forward to upgrade as soon as it is released. 🔥🔥 Approximately, what is the timeline on it? |
As with all PRs, it will land when it's fully reviewed and approved. |
…ebChromeClient.onShowFileChooser` (flutter#6881) * some progress * more work * compiling code * dart side should be correct * maybe working code * fix plugin class * formatting * some docs and polish * foramtting tests and docs * version bump * doc improvements * flutterapi create test * working java test * unused imports * formatting and more tests * formatting and more tests * formatting * copy and tests * add more description to the custom method * formatting * change doc wording * more docs * null out result early * remove the open option * fix spelling * interface implementation * version bump * move webchromeclient to webview controller * tests * reference method in changelong * missing typed data import * undo changes * use stateerror instead * updated lints
Can somebody please provide an example code to use setOnShowFileSelector, for an AndroidWebViewController. Thanks |
@kennetgo flutter/flutter#118836 is tracking that, as mentioned in the original issue. |
onShowFileChooser
.AndroidWebViewController.setOnShowFileSelector
.WebChromeClient
fromAndroidNavigationDelegate
toAndroidWebViewController
since the callback is set by the controller.Note: This callback is only supported for versions 21+.
Fixes flutter/flutter#27924 and flutter/flutter#97127
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.