Use GifImage with CachedNetworkImage
ManuelaGar opened this issue · 2 comments
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
@ManuelaGar I am currently facing this issue. I wonder if you have found a solution. If you have figured it out, please share with me. Thank you very much.
Hi @NguyenThai73 we did but this was a while ago so I don't really remember the details. Here is the link to our repository: https://github.com/ManuelaGar/gif_cache/tree/cache-manager
Let me know if you get it right :)