load method
Implementation
@override
Future<LottieComposition> load({BuildContext? context}) {
return sharedLottieCache.putIfAbsent(this, () async {
var resolved = Uri.base.resolve(url);
var client = this.client ?? http.Client();
try {
var bytes = await client.readBytes(resolved, headers: headers);
LottieComposition composition;
if (backgroundLoading) {
composition = await compute(parseJsonBytes, (bytes, decoder));
} else {
composition =
await LottieComposition.fromBytes(bytes, decoder: decoder);
}
for (var image in composition.images.values) {
image.loadedImage ??= await _loadImage(resolved, composition, image);
}
await ensureLoadedFonts(composition);
return composition;
} finally {
if (this.client == null) {
client.close();
}
}
});
}