initDefaultListFromUri static method

Future<void> initDefaultListFromUri(
  1. Uri uri
)

Initialises DefaultSuffixRules using a suffix list resource obtained from a URI.

See SuffixRules.fromString for the expected format of the suffix list.

If uri is a file:/// URI, the file is loaded using File.readAsString. For other schemes, the resource is fetched using an http request created using a simple HttpClient.

If more fine-grained control over the request is needed, consider obtaining the suffix list using custom code first and then passing it to DefaultSuffixRules.initFromString.

Implementation

static Future<void> initDefaultListFromUri(Uri uri) async {
  if (uri.isScheme('file')) {
    DefaultSuffixRules.initFromString(await _getFile(uri));
  } else {
    DefaultSuffixRules.initFromString(await _getUrl(uri));
  }
}