DataBundle.fromDataUrl constructor
DataBundle.fromDataUrl(
- String dataUrl, {
- ContentType? contentType,
Implementation
DataBundle.fromDataUrl(String dataUrl, {ContentType? contentType}) : super(dataUrl) {
try {
final UriData uriData = UriData.parse(dataUrl);
data = uriData.contentAsBytes();
_contentType = contentType ?? _contentTypeFromUriData(uriData);
} on FormatException {
// Some producers use non-standard `;utf8,` or include parameters that
// `UriData.parse`/`ContentType.parse` reject. Fall back to a tolerant parser.
final ({Uint8List bytes, ContentType type}) parsed = _parseDataUrlFallback(dataUrl);
data = parsed.bytes;
_contentType = contentType ?? parsed.type;
}
}