UriData.fromString factory constructor
UriData.fromString(Creates a data:
URI containing the content
string.
Equivalent to new Uri.dataFromString(...).data
, but may be more efficient if the uri itself isn't used.
Source
factory UriData.fromString(String content, {String mimeType, Encoding encoding, Map<String, String> parameters, bool base64: false}) { StringBuffer buffer = new StringBuffer(); List<int> indices = [_noScheme]; String charsetName; String encodingName; if (parameters != null) charsetName = parameters["charset"]; if (encoding == null) { if (charsetName != null) { encoding = Encoding.getByName(charsetName); } } else if (charsetName == null) { // Non-null only if parameters does not contain "charset". encodingName = encoding.name; } encoding ??= ASCII; _writeUri(mimeType, encodingName, parameters, buffer, indices); indices.add(buffer.length); if (base64) { buffer.write(';base64,'); indices.add(buffer.length - 1); buffer.write(encoding.fuse(BASE64).encode(content)); } else { buffer.write(','); _uriEncodeBytes(_uricTable, encoding.encode(content), buffer); } return new UriData._(buffer.toString(), indices, null); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-core/UriData/UriData.fromString.html