webviewx
webviewx copied to clipboard
Unable to click on a button in the webview. Error: Display ID mismatch found.
I have a button on the web and I'm trying to call a dart function from the web.
I tried it with Flutter version 2.8.1
and 2.10.3
but the issue persists.
Device info
- Android 12
- Pixel 3XL
Flutter code
final Set<DartCallback> dartCallBacks = {
DartCallback(
name: 'MY_BUY',
callBack: (data) {
appLogs('DartCallback -> buy: $data');
}
),
};
class BottomWidget extends StatelessWidget {
const BottomWidget({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return WebViewX(
key: const ValueKey('some-unique-value-key-here'),
height: 1000,
width: MediaQuery.of(context).size.width,
initialContent: 'https://my-server-url/',
dartCallBacks: dartCallBacks,
);
}
}
web code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Callback</title>
</head>
<body>
<button id="buy">Buy</button>
<script>
document.getElementById('buy').onclick((e) => {
MY_BUY.postMessage('AWESOME!');
});
</script>
</body>
</html>
Error in the log
[ +2 ms] D/BufferPoolAccessor2.0(27817): evictor expired: 1, evicted: 1
[+1284 ms] V/InputMethodManager(27817): b/117267690: Display ID mismatch found. ViewRootImpl displayId=15 InputMethodManager displayId=0. Use the
right InputMethodManager instance to avoid performance overhead.
[ +2 ms] V/InputMethodManager(27817): java.lang.Throwable
[ ] V/InputMethodManager(27817): at
android.view.inputmethod.InputMethodManager.getFallbackInputMethodManagerIfNecessary(InputMethodManager.java:549)
[ ] V/InputMethodManager(27817): at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:1375)
[ ] V/InputMethodManager(27817): at yJ.b(chromium-TrichromeWebViewGoogle.aab-stable-484407333:2)
[ ] V/InputMethodManager(27817): at
org.chromium.content.browser.input.ImeAdapterImpl.k(chromium-TrichromeWebViewGoogle.aab-stable-484407333:3)
[ ] V/InputMethodManager(27817): at
org.chromium.content.browser.input.ImeAdapterImpl.updateState(chromium-TrichromeWebViewGoogle.aab-stable-484407333:33)
[ ] V/InputMethodManager(27817): at android.os.MessageQueue.nativePollOnce(Native Method)
[ ] V/InputMethodManager(27817): at android.os.MessageQueue.next(MessageQueue.java:335)
[ ] V/InputMethodManager(27817): at android.os.Looper.loopOnce(Looper.java:161)
[ ] V/InputMethodManager(27817): at android.os.Looper.loop(Looper.java:288)
[ ] V/InputMethodManager(27817): at android.app.ActivityThread.main(ActivityThread.java:7842)
[ ] V/InputMethodManager(27817): at java.lang.reflect.Method.invoke(Native Method)
[ ] V/InputMethodManager(27817): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[ ] V/InputMethodManager(27817): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)