Tom3652
Tom3652

Reputation: 2967

CacheImageNetwork cache not working Flutter

I am using the cache_image_network plugin in my flutter to cache images from the network.

Unfortunately it doesn't work and i can see this "warning" :

I/flutter ( 4308): *** WARNING ***
I/flutter ( 4308): 
I/flutter ( 4308): Invalid argument null with type Null.
I/flutter ( 4308): Only num, String and Uint8List are supported. See https://github.com/tekartik/sqflite/blob/master/sqflite/doc/supported_types.md for details
I/flutter ( 4308): 
I/flutter ( 4308): This will throw an exception in the future. For now it is displayed once per type.

The url i provide is working fine, i can see my image from the network but the cache has this issue (i have turned off my internet connection & restarted the app, no image in cache).

How can i fix this please ?

I am using the latest version (at the moment this question is asked) 3.0.0 of the plugin.

EDIT : I am adding the code in case it matters :

@override
  Widget build(BuildContext context) {
    return CachedNetworkImage(
      imageUrl: url,
      maxWidthDiskCache: 200,
      maxHeightDiskCache: 200,
      placeholderFadeInDuration: Duration(milliseconds: 100),
      placeholder: (context, url) => SvgPicture.asset(
        'assets/images/Logo/logo_login_light.svg',
        width: Constants.maxHeight * 10 / 100,
        height: Constants.maxHeight * 10 / 100,
      ),
      imageBuilder: (context, imageProvider) => Container(
        decoration: BoxDecoration(
          shape: BoxShape.circle,
          image: DecorationImage(
              fit: BoxFit.fill,
              image: imageProvider
          ),
        ),
      ),
    );
  }

UPDATE :

My question is partially wrong because the CacheNetworkManager is partially working, i was using the resize attribute (200x200) which was caching 2 files :

Here are the cached files : One of them has null properties.

DB inspector screenshot

HOWEVER : After i turn off the internet connection and rebuild my app (hot reload or manual restart without IDE), i can see the cache is cleared instead of being read.

Why this behaviour ?

Thanks

Upvotes: 2

Views: 1884

Answers (2)

Tom3652
Tom3652

Reputation: 2967

So i have found the issue, i was calling myself a new instance of the DefaultCacheManager class somewhere else in my app and it was causing the trouble (deleting the cache of the CacheNetworkImage)...

As weird as it is, it may help others !

Upvotes: 1

ShinMyth
ShinMyth

Reputation: 644

Good day.. were you able to declare the value for the url variable you're using on the imageUrl property...

if not add the value on the url variable or better yet input the network image's url on the imageUrl property directly..

Upvotes: 0

Related Questions