looksLikeSvg function
Whether bytes start like an SVG document: an <svg element near the
start, after any XML declaration, doctype or comment.
Checked before the bytes reach the SVG decoder, which reports bad input as an uncaught error on top of its error widget.
Implementation
bool looksLikeSvg(Uint8List bytes) {
final head = String.fromCharCodes(
bytes.length > 2048 ? bytes.sublist(0, 2048) : bytes,
).toLowerCase();
return head.contains('<svg');
}