removeFromCache static method

Future<void> removeFromCache(
  1. String url, {
  2. bool showDebugLogs = false,
})

Static method to remove a URL from the proxy cache Use this to remove a URL that was previously marked as requiring a proxy The next load attempt will try a direct connection without the proxy

Example usage:

Stack(children: [
  SWebView(url: 'https://example.com'),
  Positioned(
    top: 10,
    right: 10,
    child: PointerInterceptor(
      child: ElevatedButton(
        onPressed: () => SWebView.removeFromCache('https://example.com'),
        child: Text('Clear Proxy Cache'),
      ),
    ),
  ),
])

Implementation

static Future<void> removeFromCache(
  String url, {
  bool showDebugLogs = false,
}) async {
  if (kDebugMode && showDebugLogs) {
    debugPrint('SWebView: Removing $url from proxy cache');
  }

  final key = _SWebViewState.cacheKeyFromUrl(url, cacheByHost: true);
  _SWebViewState._restrictionCache.remove(key);
  await _SWebViewState._saveCache(showDebugLogs: showDebugLogs);
}