Flutter Network Image does not fit in Circular Avatar

后端 未结 23 1143
走了就别回头了
走了就别回头了 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:36

    If you want to show your image covering whole width of circle avatar then you can use it like this way. And if your image didnot load then it will show default person icon.

     CircleAvatar(
                  child: ClipOval(
                                      child: Center(
                                    child: _image == null
                                        ? Icon(
                                            Icons.person,
                                            color: Colors.grey.shade700,
                                            size: 100,
                                          )
                                        : Image.file(
                                            _image,
                                            fit: BoxFit.cover,
                                            width: MediaQuery.of(context).size.width,
                                          ),
                                  ),
                                ),
    
                              radius: 50,
                              backgroundColor: Colors.grey.shade300,
                            ),
    

提交回复
热议问题