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.
factory UriData.fromUri(Uri uri) { if (uri.scheme != "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", 5, uri); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-core/UriData/UriData.fromUri.html