fromSvgBytes method

Future<DrawableRoot> fromSvgBytes(
  1. Uint8List raw,
  2. String key, {
  3. SvgTheme theme = const SvgTheme(),
})

Produces a Drawableroot from a Uint8List of SVG byte data (assumes UTF8 encoding).

The key will be used for debugging purposes.

Implementation

Future<DrawableRoot> fromSvgBytes(
  Uint8List raw,
  String key, {
  SvgTheme theme = const SvgTheme(),
}) async {
  // TODO(dnfield): do utf decoding in another thread?
  // Might just have to live with potentially slow(ish) decoding, this is causing errors.
  // See: https://github.com/dart-lang/sdk/issues/31954
  // See: https://github.com/flutter/flutter/blob/bf3bd7667f07709d0b817ebfcb6972782cfef637/packages/flutter/lib/src/services/asset_bundle.dart#L66
  // if (raw.lengthInBytes < 20 * 1024) {
  return fromSvgString(utf8.decode(raw), key, theme: theme);
  // } else {
  //   final String str =
  //       await compute(_utf8Decode, raw, debugLabel: 'UTF8 decode for SVG');
  //   return fromSvgString(str);
  // }
}