createListFromUri static method

Future<SuffixRules> createListFromUri(
  1. Uri uri
)

Creates a SuffixRules object 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 SuffixRules.fromString.

Implementation

static Future<SuffixRules> createListFromUri(Uri uri) async {
  if (uri.isScheme('file')) {
    return SuffixRules.fromString(await _getFile(uri));
  } else {
    return SuffixRules.fromString(await _getUrl(uri));
  }
}