UriData.fromUri constructor
- 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.
Implementation
factory UriData.fromUri(Uri uri) {
if (!uri.isScheme("data")) {
throw ArgumentError.value(uri, "uri", "Scheme must be 'data'");
}
if (uri.hasAuthority) {
throw ArgumentError.value(uri, "uri", "Data uri must not have authority");
}
if (uri.hasFragment) {
throw 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.toString(), 5, uri);
}