flutter_webview_plugin
flutter_webview_plugin copied to clipboard
Implement onJSAlert, onJSConfirm, onJSPrompt interface
Related issue: #376, enhanced Pull request by: #522.
Instead of implement native code, I advocate it handling that flutter side. I extract both iOS and Android native callback into three functions.
Native callback
Android | iOS | |
---|---|---|
Alert | public boolean onJsAlert(WebView view, String url, String message, final JsResult result) | webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:) |
Confirm | public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) | webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:) |
Prompt | public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) | webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:) |
Flutter callback
Flutter | |
---|---|
Alert | flutterWebViewPlugin.onJSAlert = (alert) async { }; |
Confirm | flutterWebViewPlugin.onJSConfirm = (confirm) async { }; |
Prompt | flutterWebViewPlugin.onJSPrompt = (prompt) async { }; |
Also, I filled up the example.
Thank you for PR and sorry for long review time, I am quite busy these days. I will review this asap, although code doesn't work for me for example project.
@j796160836 conflicted
Any updates on this feature?