fromAvdBytes method

Future<DrawableRoot> fromAvdBytes(
  1. Uint8List raw,
  2. String key
)

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

The key parameter is used for debugging purposes.

Implementation

Future<DrawableRoot> fromAvdBytes(Uint8List raw, String key) 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 fromAvdString(utf8.decode(raw), key);
  // } else {
  //   final String str =
  //       await compute(_utf8Decode, raw, debugLabel: 'UTF8 decode for SVG');
  //   return fromSvgString(str);
  // }
}