Flutter Network Image does not fit in Circular Avatar

后端 未结 23 1181
走了就别回头了
走了就别回头了 2020-12-29 02:06

I am trying to retrieve bunch of images from an api. I want the images to be displayed in Circular form so I am using CircleAvatar Widget, but I keep getting im

23条回答
  •  不思量自难忘°
    2020-12-29 02:31

    This Will Work : You need to use backgroundImage:property in order to fit it in Circle.

    CircleAvatar(
                    radius: 30.0,
                    backgroundImage:
                        NetworkImage("${snapshot.data.hitsList[index].previewUrl}"),
                    backgroundColor: Colors.transparent,
                  )
    

    To Check with Dummy Placeholder:

    CircleAvatar(
                    radius: 30.0,
                    backgroundImage:
                        NetworkImage('https://via.placeholder.com/150'),
                    backgroundColor: Colors.transparent,
                  )
    

提交回复
热议问题