简体   繁体   中英

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

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,
                    );
                  }),
                ),

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.'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM