Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingPluginException when calling InAppWebViewController #336

Closed
AlexV525 opened this issue May 11, 2020 · 4 comments
Closed

MissingPluginException when calling InAppWebViewController #336

AlexV525 opened this issue May 11, 2020 · 4 comments

Comments

@AlexV525
Copy link
Contributor

Environment

Flutter version: 1.17.0 (stable)
Plugin version: 3.1.0
Android version: Android 10
Device information: Emulator/OnePlus IN2020

Description

Calling any methods in InAppWebViewController throws an unimplement error.

Steps to reproduce

  1. Implement a webView widget in some pages.
  2. Define method onWebViewCreated and inside this call _webViewController = controller.
  3. Call _webViewController.evaluateJavascript(...) or any methods and it throws error.

Images

image

image

Stacktrace/Logcat

E/flutter (16827): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_1)
E/flutter (16827): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter (16827): <asynchronous suspension>
E/flutter (16827): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (16827): #2      InAppWebViewController.evaluateJavascript (package:flutter_inappwebview/src/in_app_webview_controller.dart:926:31)
E/flutter (16827): #3      _InAppBrowserPageState.dispose (package:openjmu/widgets/webview/in_app_webview.dart:91:24)
......
@AlexV525
Copy link
Contributor Author

@pichillilorenzo I think it might be related to id with the channel?

@pichillilorenzo
Copy link
Owner

This behavior is correct. That happens in your case because you are calling the webview controller method inside the dispose() widget method.
Any webview controller method, such as evaluateJavascript is an async method, so execute asynchronously. It means that when you call a webview controller method at dispose widget time, your webview has already been disposed (it has been removed from the widget tree), so you can't communicate with it, because there isn't any webview anymore.
If you need to set window.onbeforeunload=null with javascript, you need to do it before the dispose widget method is called! For example, you can place it in the onLoadStop method.

@AlexV525
Copy link
Contributor Author

Okay, but the reason I'm override onBeforeUnload is from another issue, I'll open it later.

BTW, glad to see you coming back after these months. 😄

This was referenced Jul 6, 2020
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants