Flutter实现圆形图片的两种方法

方法一:

Widget buildCircleImage(double size, ImageProvider provider) {

  return SizedBox(

   width: size,

    height: size,

    child: DecoratedBox(

      decoration: BoxDecoration(

          shape: BoxShape.circle,

          image: DecorationImage(image: provider, fit: BoxFit.cover)),

    ),

  );

}


方法二:

Widget buildCircleImage2(double size, ImageProvider provider) {

  return ClipOval(

      child: Image(

     image: provider,

     width: size,

    height: size,

    fit: BoxFit.cover,

  ));

}

具体demo见:https://github.com/liaobushi520/fake_wechat

你可能感兴趣的:(Flutter实现圆形图片的两种方法)