clearCache method

  1. @override
Future<void> clearCache()

Clears all caches used by the WebView.

The following caches are cleared: 1. Browser HTTP Cache. 2. Cache API caches. These are not yet supported in iOS WkWebView. Service workers tend to use this cache. 3. Application cache.

Implementation

@override
Future<void> clearCache() {
  return _webView.configuration.websiteDataStore.removeDataOfTypes(
    <WKWebsiteDataType>{
      WKWebsiteDataType.memoryCache,
      WKWebsiteDataType.diskCache,
      WKWebsiteDataType.offlineWebApplicationCache,
    },
    DateTime.fromMillisecondsSinceEpoch(0),
  );
}