I'm trying to extract frames from an animated gif using Flutter. By researching the Flutter API, I thought the following code should work but it only gives me the first frame although it gives me the correct frames count.
static Future<List<ui.Image>> loadAnimatedGif(String assetPath) async { List<ui.Image> gifImage = []; ByteData data = await rootBundle.load(assetPath); var codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); int frmCnt = codec.frameCount; print("frmcnt is $frmCnt"); //it gives correct frames count for (int i = 0; i < frmCnt; i++) { var frame = await codec.getNextFrame(); gifImage.add(frame.Image); } return gifImage; }