pierluigizagaria / flutter_gif

Gif image widget that helps to controll gif progress and speed
https://pub.dev/packages/gif
MIT License
5 stars 11 forks source link

šŸ› Error: The method 'instantiateImageCodec' isn't defined for the class 'PaintingBinding'. #8

Open Taha-Firoz opened 3 weeks ago

Taha-Firoz commented 3 weeks ago

I was trying to use this library in rendering my gifs. I am not using a controller, I'm just passing an ImageProvider without a controller. I've attached my flutter doctor output and the complete error message.

I already had gifs rendering and working but I would need to evict them frequently because I have a variable number of gifs that render at once.

Transform.rotate(
  angle: rotation * pi / 180,
  child: 
  Image(
    image: imgSrc,
    width: 200,
    height: 200,
  ),
),

I swapped it to:

Transform.rotate(
  angle: rotation * pi / 180,
  child:
    Gif(
      image: imgSrc,
      autostart: Autostart.once,
      placeholder: (context) => const Text('Loading...'),
      onFetchCompleted: () {
      },
    )
),
AppData/Local/Pub/Cache/hosted/pub.dev/gif-2.2.0/lib/gif.dart:348:51: Error: The method 'instantiateImageCodec' isn't defined for the class 'PaintingBinding'.
 - 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/C:/flutter/packages/flutter/lib/src/painting/binding.dart').
Try correcting the name to the name of an existing method, or defining a method named 'instantiateImageCodec'.
    Codec codec = await PaintingBinding.instance!.instantiateImageCodec(bytes);

Flutter Doctor:

[āˆš] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22631.4037], locale en-US)
[āˆš] Windows Version (Installed version of Windows is version 10 or higher)
[āˆš] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[āˆš] Chrome - develop for the web
[āˆš] Android Studio (version 2022.3)
[āˆš] Android Studio (version 2023.1)
[āˆš] VS Code (version 1.92.2)
[āˆš] Connected device (3 available)
[āˆš] Network resources
tigrenok00 commented 2 weeks ago

Same error here, flutter 3.16.0

Gif( image: AssetImage("assets/img/animation/ar_calib.gif"), fps: 30, ),