【问题标题】:There is any method for webview cache Optimization in flutter?Flutter中有什么方法可以进行webview缓存优化吗?
【发布时间】:2021-03-01 16:13:34
【问题描述】:
我使用 flutter_inappwebview 将网站提取到 Flutter 应用程序中。我想在 webview 启动期间将所有资源(如 JS 和 CSS 文件内容)从网站保存到缓存中,然后当我调用同一个网站时,资源将拦截并将缓存的文件注入 webview。这可能吗..如果可能,那么如何..请举例说明。谢谢。
【问题讨论】:
标签:
flutter
dart
optimization
flutter-inappwebview
【解决方案2】:
flutter_inappwebview 包已经有一个属性,cacheEnabled,默认参数为 true。你不需要对此做任何事情。如果不想存储缓存文件,可以设置为false。
///Sets whether WebView should use browser caching. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
bool cacheEnabled;
并且,clearCache 属性的默认值是 'false'。
///Set to `true` to have all the browser's cache cleared before the new WebView is opened. The default value is `false`.
bool clearCache;