2

I am using a CircleAvatar with a backgroundImage property to load an image took from memory but I get the error How I can set the image.memory in the CircleAvatar in flutter?

    String url = "$GetImageDataUrl/$serviceId/image";
    final ByteData imageData = await NetworkAssetBundle(Uri.parse(url)).load("");
    final Uint8List bytes = imageData.buffer.asUint8List();
   
CircleAvatar(
  backgroundImage: image.memory(bytes),  // get error
)

I can not using the image.Network

Masoud H
  • 194
  • 4
  • 15

1 Answers1

6

checkout below code it may help you,

CircleAvatar widget backgroundImage property you can't assign Image type to ImageProvider.

Use MemoryImage

ByteData imageData = await rootBundle.load('assets/images/test.png');
Uint8List bytes = imageData.buffer.asUint8List();
CircleAvatar(
  radius: 30.0,
  backgroundImage: MemoryImage(bytes), //here
)
Jai Techie
  • 1,657
  • 3
  • 14
  • 36