Flutter的Webview-如何清除 session 状态?

标签 flutter webview

我有一个可以登录到特定页面并通过Javascript执行一些命令的应用程序。但是,当我再次启动该应用程序时,应打开登录表单。但是,相反,它将保持记录状态并转到用户的屏幕。

        child: WebView(
              initialUrl:
                  'https://thepage.com/m/customer/account/login/',
              onWebViewCreated: (c) {
                _webviewController = c;
                print("cleaning the cache");
                _webviewController.clearCache();
              },
              onPageFinished: (String page) async {
                setState(() {
                  _isPageLoaded = true;
                });
              },
              javascriptMode: JavascriptMode.unrestricted,
            ),

我试图清除缓存,但可能还不够。
I/zygote64( 5259): Compiler allocated 6MB to compile void android.view.ViewRootImpl.performTraversals()
I/flutter ( 5259): cleaning the cache

最佳答案

我认为问题在于您没有清除Cookie。我在登录页面时遇到了同样的问题,并且保持登录状态,这是通过清除onWebViewCreated回调中的cookie来解决的:

onWebViewCreated: (webViewController) {
    _controller.complete(webViewController);
    webViewController.clearCache();
    final cookieManager = CookieManager();
    cookieManager.clearCookies();
},

关于Flutter的Webview-如何清除 session 状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57021584/

相关文章:

flutter - GestureDetector 在滚动时不接收事件

flutter - Dart 未处理异常 : FormatException: Invalid radix-10 number (at character 1)

android - SslErrorHandler proceed() 函数的实现

Firebase实时数据库Flutter流永不返回问题

flutter:什么时候重建 const 小部件?

javascript - UIWebView scrollTo 应该表现流畅

html - iOS:运行 webview 时排除某些 URL

android - reCaptcha 无法在 Android Webview 上停止循环

c# - 为什么我无法在 WebView (UWP) 中打开外部浏览器中的链接?

android-studio - 读取超时错误builder.jar(com.android.tools.build:builder:3.2.1)-Flutter-Android Studio