setSafeBrowsingAllowlist method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebViewCompat.setSafeBrowsingAllowlist', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST].')])
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.
hosts represents the list of hosts. This value must never be null.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebViewCompat.setSafeBrowsingAllowlist):
- This method should only be called if WebViewFeature.isFeatureSupported returns
truefor WebViewFeature.SAFE_BROWSING_ALLOWLIST.
- This method should only be called if WebViewFeature.isFeatureSupported returns
Parameters - Officially Supported Platforms/Implementations:
hosts: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebViewCompat.setSafeBrowsingAllowlist',
apiUrl:
'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)',
note:
'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST].',
),
],
)
Future<bool> setSafeBrowsingAllowlist({required List<String> hosts}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.setSafeBrowsingAllowlist.name} is not implemented on the current platform',
);
}