fetchGif method
Implementation
Future<List<ImageInfo>?> fetchGif(ImageProvider provider) async {
var data = ByteData(0);
if (provider is AssetImage) {
// ignore: use_named_constants
final key = await provider.obtainKey(const ImageConfiguration());
data = await key.bundle.load(key.name);
final codec = await instantiateImageCodec(data.buffer.asUint8List());
if (infos?.isEmpty == true) {
for (var i = 0; i < codec.frameCount; i++) {
try {
final frameInfo = await codec.getNextFrame();
infos?.add(ImageInfo(image: frameInfo.image));
} on Exception catch (e) {
debugPrint(e.toString());
}
}
}
}
return infos;
}