Skip to content

Use GifImage with CachedNetworkImage #16

@ManuelaGar

Description

@ManuelaGar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions