I am trying to decode some animated webp files in dart but getting the runtime error of 'index out of range and it should be less than N. and N is the size of file in bytes. But images other than this folder works fine.
Link of animated webp files I used https://github.com/WhatsApp/stickers/tree/main/Android/app/src/main/assets/2
Dart Code:
import 'dart:io';
import 'package:image/image.dart';
void main() {
final image = 'asset/ok.webp';
File bytes = File(image);
List<int> list = bytes.readAsBytesSync();
// list.length = 85538
Animation anim = decodeWebPAnimation(list)!;
// runtime error raised from decodeWebPAnimation()
}
Console:
Exception has occurred.
IndexError (RangeError (index): Index out of range: index should be less than 5292: 5292)
Tools versions:
Flutter 2.10.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 097d3313d8 (6 days ago) • 2022-02-18 19:33:08 -0600
Engine • revision a83ed0e5e3
Tools • Dart 2.16.1 • DevTools 2.9.2
PS: I have checked similar question on stackoverflow but that is based on the Flutter UI components so The error causing from the component and the answers are related to the UI components only.