setSafeBrowsingWhitelist static method
Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.
Each rule should take one of these:
Rule | Example | Matches Subdomain |
---|---|---|
HOSTNAME | example.com | Yes |
.HOSTNAME | .example.com | No |
IPV4_LITERAL | 192.168.1.1 | No |
IPV6_LITERAL_WITH_BRACKETS | 10:20:30:40:50:60:70:80 |
No |
All other rules, including wildcards, are invalid. The correct syntax for hosts is defined by RFC 3986.
This method should only be called if AndroidWebViewFeature.isFeatureSupported returns true
for AndroidWebViewFeature.SAFE_BROWSING_ALLOWLIST.
hosts
represents the list of hosts. This value must never be null
.
Official Android API: https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)
Implementation
static Future<bool> setSafeBrowsingWhitelist(
{required List<String> hosts}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('hosts', () => hosts);
return await _staticChannel.invokeMethod('setSafeBrowsingWhitelist', args);
}