Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter The argument type 'FadeInImage' can't be assigned to the parameter type 'ImageProvider<Object>?

Tags:

flutter

dart

guys any way to put a fadeInImage as a background of a cicrle avatar? i'm trying but i get this compiler error

The argument type 'FadeInImage' can't be assigned to the parameter type 'ImageProvider<Object>?'

this is my circle avatar

child: Obx(() {
                    return CircleAvatar(
                      backgroundColor: Colors.grey,
                      backgroundImage: NetworkImage(
                        controller.urlImagem.value.toString(),
                      ),
                      maxRadius: 100,
                    );
                  }),

I want to put this code but this error appears to me at the top

child: Obx(() {
                    return CircleAvatar(
                      backgroundColor: Colors.grey,
                      
                      backgroundImage: controller.urlImagem.value.isNotEmpty ? FadeInImage.memoryNetwork(placeholder: kTransparentImage, image: controller.urlImagem.value) : null,
                      maxRadius: 100,
                    );
                  }),
                ),
like image 741
flavio_vieira_stack Avatar asked Sep 05 '25 14:09

flavio_vieira_stack


1 Answers

Had the same question since the Flutter example didn't mention anything else about it. The solution came from the transparent_image GitHub repo, which is to wrap kTransparentImage in a MemoryImage:

MemoryImage(kTransparentImage);

From the documentation MemoryImage 'Creates an object that decodes a Uint8List buffer as an image.'

like image 97
PabloJ Avatar answered Sep 08 '25 12:09

PabloJ