pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.09k stars 1.39k forks source link

webStorage.localStorage.removeItem(key: key); throws MissingPluginException #1077

Open DanielGZ95 opened 2 years ago

DanielGZ95 commented 2 years ago

Environment

Technology Version
Flutter version 2.5.2
Plugin version 5.3.2
Android version 9
iOS version X
Xcode version X

Device information: All android devices

Description

Expected behavior: Before closing the widget that contains web view, we want to delete session data from local storage. The data should be deleted correctly.

Current behavior: Before closing the widget that contains web view, we want to delete session data from local storage. The data is not deleted and there is an exception thrown by the library.

Steps to reproduce

 @override
  void dispose() async {
    try {
      _controller?.removeFromStorage('email');
      _controller?.removeFromStorage('token');
    } on Exception catch (_) {
      print(
        'Not able to delete session data',
      );
    }
    super.dispose();
  }

extension InAppWebControllerExtension on InAppWebViewController {
  void removeFromStorage(String key) async {
    webStorage.localStorage.removeItem(key: key);
  }
}

Stacktrace/Logcat

E/flutter (32322): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_5)
E/flutter (32322): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): #1      InAppWebViewController.evaluateJavascript (package:flutter_inappwebview/src/in_app_webview/in_app_webview_controller.dart:1375:16)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): #2      Storage.removeItem (package:flutter_inappwebview/src/web_storage/web_storage.dart:92:5)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): 
E/flutter (32322): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_5)
E/flutter (32322): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): #1      InAppWebViewController.evaluateJavascript (package:flutter_inappwebview/src/in_app_webview/in_app_webview_controller.dart:1375:16)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): #2      Storage.removeItem (package:flutter_inappwebview/src/web_storage/web_storage.dart:92:5)
E/flutter (32322): <asynchronous suspension>
E/flutter (32322): 
W/chromium(32322): [WARNING:spdy_session.cc(3491)] Received HEADERS for invalid stream 7
github-actions[bot] commented 2 years ago

👋 @DanielGZ95

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!