retryWithProxy static method

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

Static method to load a URL via CORS proxy Can be called from custom buttons stacked over the widget This will mark the URL for proxy usage and trigger a reload

Example usage:

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

Implementation

static Future<void> retryWithProxy(
  String url, {
  bool showDebugLogs = false,
}) async {
  final key = _SWebViewState.cacheKeyFromUrl(url, cacheByHost: true);
  _SWebViewState._restrictionCache[key] = _RestrictionCacheEntry(
    needsProxy: true,
    updatedAtMillis: DateTime.now().millisecondsSinceEpoch,
  );
  await _SWebViewState._saveCache(showDebugLogs: showDebugLogs);
}