UriData.fromUri(Uri uri)

Creates a DataUri from a Uri which must have data as Uri.scheme.

The uri must have scheme data and no authority or fragment, and the path (concatenated with the query, if there is one) must be valid as data URI content with the same rules as parse.

Source

factory UriData.fromUri(Uri uri) {
  if (uri.scheme != "data") {
    throw new ArgumentError.value(uri, "uri",
                                  "Scheme must be 'data'");
  }
  if (uri.hasAuthority) {
    throw new ArgumentError.value(uri, "uri",
                                  "Data uri must not have authority");
  }
  if (uri.hasFragment) {
    throw new ArgumentError.value(uri, "uri",
                                  "Data uri must not have a fragment part");
  }
  if (!uri.hasQuery) {
    return _parse(uri.path, 0, uri);
  }
  // Includes path and query (and leading "data:").
  return _parse("$uri", 5, uri);
}