Giter VIP home page Giter VIP logo

flutter_gifimage's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_gifimage's Issues

IOS出现闪退

内存溢出了

class SplashWidget extends StatefulWidget {
  SplashWidget({Key key}) : super(key: key);

  @override
  _SplashWidgetState createState() => _SplashWidgetState();
}

class _SplashWidgetState extends State<SplashWidget>
    with TickerProviderStateMixin {
  GifController gifController;

  @override
  void initState() {
    super.initState();
    gifController =
        GifController(vsync: this, duration: Duration(milliseconds: 500))
          ..addListener(() {
            if (gifController.value.ceil() >= 80) {
              gifController.stop();
              gifController.dispose();
              gifController = null;
            }
          });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: GifImage(
        image: AssetImage(A.assetsImagesAppWelcome),
        controller: gifController,
        fit: BoxFit.contain,
        onFetchCompleted: () {
          gifController.repeat(
              min: 2, max: 91, period: Duration(milliseconds: 500));
        },
      ),
    );
  }
}

Image.asset问题请教

你好,为什么我用普通的Image.asset放入gif之后,从另一页面返回后只停留在gif的第一帧?用了GifImage之后是最后一帧?这里哪段代码处理这个问题呢?

addListener was called on null

Whenever I ran the controller, it is crashing.

The method 'addListener' was called on null.
Receiver: null
Tried calling: addListener(Closure: () => void from Function '_listener@47216319':.)

in my class:

class Foo extends State<Bar> with TickerProviderStateMixin {
GifController gifController;

 @override
  void initState() {
  ...
    gifController = GifController(vsync: this);
    WidgetsBinding.instance.addPostFrameCallback((_){
      gifController.repeat(min: 0,max: 53,period: Duration(milliseconds: 200));
    });
    super.initState();
  }

...

@override
  Widget build(BuildContext context) {
...
 return Container(
...
 GifImage(
    controller: gifController,
    image: AssetImage("assets/inkman-hour-tick.gif"),
 ),
}
...

Exception: Could not instantiate image codec.

Unhandled Exception: Exception: Could not instantiate image codec.
E/flutter ( 3260): #0 _futurize (dart:ui/painting.dart:4304:5)
E/flutter ( 3260): #1 instantiateImageCodec (dart:ui/painting.dart:1682:10)
E/flutter ( 3260): #2 PaintingBinding.instantiateImageCodec (package:flutter/src/painting/binding.dart:88:12)
E/flutter ( 3260): #3 fetchGif (package:flutter_gifimage/flutter_gifimage.dart:243:49)

tried with

https://www.howtogeek.com/wp-content/uploads/2019/09/2.gif

return Align(
    child: GifImage(
      image: FileImage(File(path)),
      controller: _gitController,
    ),
    alignment: Alignment.center);

Error with instantiateImageCodec method in gif package Description: I encountered an error while using the gif package in my Flutter project. The error message indicates that the method instantiateImageCodec is not defined for the class PaintingBinding.

../../../../.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' ('../../../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);

I have ensured that I am using the latest versions of both Flutter and the gif package. However, I am still encountering this issue. Could you please provide guidance on how to resolve this error? If the method instantiateImageCodec has been deprecated or removed, I would appreciate information on alternative methods or any necessary code changes.

Unhandled Exception: Unsupported operation: Infinity or NaN toInt

Tried with this:

https://www.howtogeek.com/wp-content/uploads/2019/09/2.gif (I downloaded to my sd card..)

return Align(
    child: GifImage(
      image: FileImage(File(path)),
      controller: _gifController,
      onFetchCompleted: () {
        _gifController.repeat(period: Duration(milliseconds: 300));
      },
    ),
    alignment: Alignment.center);

got an exception:

Unhandled Exception: Unsupported operation: Infinity or NaN toInt
E/flutter ( 4817): #0 double.toInt (dart:core-patch/double.dart:194:36)
E/flutter ( 4817): #1 GifImageState.didChangeDependencies.. (package:flutter_gifimage/flutter_gifimage.dart:163:49)
E/flutter ( 4817): #2 State.setState (package:flutter/src/widgets/framework.dart:1148:30)
E/flutter ( 4817): #3 GifImageState.didChangeDependencies. (package:flutter_gifimage/flutter_gifimage.dart:160:11)
E/flutter ( 4817): #4 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter ( 4817): #5 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 4817): #6 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter ( 4817): #7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter ( 4817): #8 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter ( 4817): #9 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter ( 4817): #10 Future._asyncComplete. (dart:async/future_impl.dart:554:7)
E/flutter ( 4817): #11 _rootRun (dart:async/zone.dart:1126:13)

Without repeat

How to animate gif without repeat? If i dont use repeat, gif won't display at all

How to get number of frames and frame delay?

Is there a way to get info of the GIF image about frames count and frame delay?

Some functions like repeat require max argument but I don't know the exact number of GIF frames. Specially when that GIF image is coming from network.

Also when the GIF has no frame delay information, the playback goes too fast. It should be defaulted to about 100ms if there is no delay information provided.

Use GifImage with CachedNetworkImage

Dear peng8350,

First I would like to thank you for creating such an awesome and useful library. I am currently building an app for deaf people and I need to use many gifs for them to see in their language the meaning of all the objects in the app.
My problem is that as I need to use many gifs, I cannot keep them in a local file because it will make the app too heavy for upload in the stores.
I am trying to implement your GifImage widget (which works perfectly) with CachedNetworkImage like so:

CachedNetworkImage(
              imageUrl:
                  'https://firebasestorage.googleapis.com/v0/b/app-lsc-7310d.appspot.com/o/test.gif?alt=media',
              imageBuilder: (context, imageProvider) => GifImage(
                controller: controller,
                image: imageProvider,
              ),
              placeholder: (context, url) => CircularProgressIndicator(),
              errorWidget: (context, url, error) => Icon(Icons.error),
            ),

But I get an error because if I put the imageProvider in your image (although both are imageProvider objects, in your function I guess this alternative is not considered, so I get the following error:

[VERBOSE-2:shell.cc(242)] Dart Unhandled Exception: NoSuchMethodError: The getter 'buffer' was called on null.
Receiver: null
Tried calling: buffer, stack trace: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      fetchGif (package:flutter_gifimage/flutter_gifimage.dart:243:76)
#2      GifImageState.didChangeDependencies (package:flutter_gifimage/flutter_gifimage.dart:158:7)
#3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4653:11)
#4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4469:5)
#5      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
#6      Element.updateChild (package:flutter/src/widgets/framework.dart:3303:20)
#7      SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5981:14)
#8      Element.updateChild (package:flutter/src/widgets/framework.dart:3293:15)
#9      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
#10<>

Do you think you can help me figure out how I can implement both libraries and for them to work good together?

Best regards,

Manuela

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.