dartflutter-image

flutter CachedNetworkImageProvider is not working


CircleAvatar(
                    radius: 40.0,
                    backgroundColor: Colors.blue,
                    backgroundImage: 
                        user.profileImageUrl.isEmpty 
                            ? AssetImage('assets/images/user.png') 
                            : CachedNetworkImageProvider(user.profileImageUrl),
                  ),

It says the 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.

and when I hit the flutter run, it is giving me the following

/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-1.1.3/lib/src/cached_network_image_provider.dart:42:24: Error: The method 'CachedNetworkImageProvider.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.  
  ImageStreamCompleter load(CachedNetworkImageProvider key) {
                       ^
/D:/Flutter/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
  ImageStreamCompleter load(T key, DecoderCallback decode);
                       ^

Solution

  • Make sure you are using rc version of cached_network_image.

    Add this to your pubspec.yaml file cached_network_image: ^2.0.0-rc and run flutter pub get