网页浏览是否在抖动的网页中? [英] Do the webview in flutter cached web page?

查看:69
本文介绍了网页浏览是否在抖动的网页中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想缓存显示在Flutter Webview中的网页,从而提高性能,而无需重新加载页面.有空吗?我可以实施吗?

解决方案

flutter_inappwebview(以前为flutter_inappbrowser)
具有参数cacheEnabled,默认值为ture
cacheEnabled:设置WebView是否应使用浏览器缓存.默认值为true

flutter_webview_plugin社区版本
具有参数appCacheEnabled以启用缓存

WebviewScaffold(
    key: _scaffoldKey,
    url: widget.url,
    clearCache: true,
    appCacheEnabled: true,      
);

webview_flutter官方版本
不提供参数,可以查看Android源代码 https://developer.android.com/reference/android/webkit/WebSettings# LOAD_DEFAULT
默认缓存使用模式.如果导航类型没有任何特定行为,请在缓存资源可用且未过期时使用缓存的资源,否则请从网络加载资源

I want to cache the web page I display in flutter webview so to improve my performance, no need to reload the page. Is that available? and can I implement it?

解决方案

flutter_inappwebview(former flutter_inappbrowser)
Has parameter cacheEnabled and default is ture
cacheEnabled: Sets whether WebView should use browser caching. The default value is true

flutter_webview_plugin community version
Has parameter appCacheEnabled to enable cache

WebviewScaffold(
    key: _scaffoldKey,
    url: widget.url,
    clearCache: true,
    appCacheEnabled: true,      
);

webview_flutter official version
Do not provide parameter , you can check with Android Source code https://github.com/flutter/plugins/blob/master/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java

default cache mode depend on iOS WKWebView and Android WebView
default cache mode of Android WebView is LOAD_DEFAULT https://developer.android.com/reference/android/webkit/WebSettings#LOAD_DEFAULT
Default cache usage mode. If the navigation type doesn't impose any specific behavior, use cached resources when they are available and not expired, otherwise load resources from the network

这篇关于网页浏览是否在抖动的网页中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆