Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void saveGif(String fileName, Iterable<Image> frames, {double fps = 24}) {
- final int frameDuration = (100 / fps).round();
- final GifEncoder encoder = GifEncoder(delay: 0, repeat: 0);
- for (Image frame in frames) {
- encoder.addFrame(frame, duration: frameDuration);
- }
- final Uint8List? image = encoder.finish();
- if (image != null) {
- File(fileName).writeAsBytesSync(image);
- } else {
- throw Exception('Failed to encode GIF.');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement