fromSIAsset static method
Future<ScalableImage>
fromSIAsset(
- AssetBundle b,
- String key, {
- bool compact = false,
- Color? currentColor,
Create an image from a .si
file in an asset bundle.
Loading a .si
file is considerably faster than parsing an SVG
or AVD file - about 5-20x faster in informal measurements, for
reasonably large files. A .si
file can be created with dart run jovial_svg:svg_to_si
or
dart run jovial_svg:avd_to_si
.
If compact
is true, the internal representation will occupy
significantly less memory, at the expense of rendering time. See
toDag for a discussion of the two representations.
See also ScalableImage.currentColor.
Implementation
static Future<ScalableImage> fromSIAsset(AssetBundle b, String key,
{bool compact = false, Color? currentColor}) async {
final ByteData data = await b.load(key);
final c =
ScalableImageCompact.fromByteData(data, currentColor: currentColor);
if (compact) {
return c;
} else {
return c.toDag();
}
}