image & ClipOval & circle- flutter

child: Container(
        //子元素图片
        child: Image.asset(
            'images/ali.jfif',
            alignment: Alignment.center,
            color: Colors.green, // color 和 colorBlendMode 设置图片的混合色, 一般不使用
            colorBlendMode: BlendMode.screen,
            fit: BoxFit.cover,  //BoxFit.cover 图片不变形(宽高比不变), 充满容器, 超出宽或者超出高将被剪裁. BoxFit.fill 填充, 会拉伸变形. BoxFit.contain全局显示, 宽高比不对会有空隙.
            repeat: ImageRepeat.repeat, //图片平铺效果
        ),
        height:300,
        width: 300,
        // alignment: Alignment.topLeft, //容器子元素对齐方式
        decoration: BoxDecoration(
          color: Colors.orange, //容器背景色
          border: Border.all(
            color: Colors.pink,
            width: 2.0
          ),
          //容器实现圆角 + 容器背景形状随容器形状
          // borderRadius: BorderRadius.all( //容器圆角
          //   Radius.circular(150)
          // ),
          borderRadius: BorderRadius.circular(200), //设置容器圆角, 背景图片被容器轮廓切成圆的, (必须是背景图片, child子类的image元素是不可以的)
          image: DecorationImage( //容器背景图片
            image:NetworkImage(
              "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1606228192857&di=8290dfcf5d14afdabcb11e67ae675320&imgtype=0&src=http%3A%2F%2Fpic.rmb.bdstatic.com%2F9d7596f4813e84e48fa247548251d3ed.jpeg%40c_1%2Cw_700%2Ch_700%2Cx_0%2Cy_0",
            ),
            fit: BoxFit.cover
          ),
        ),
      )
 child: Container(
        decoration: BoxDecoration(
          color: Colors.orange
        ),
        child: ClipOval(  //实现圆形图片, container容器的child子元素 Clipoval是一个圆形盒子, 所以设置子元素图片形状跟随父盒子即可
          child: Image.asset(
          	height: 60,  //调整图片宽高保证其是个原型
          	width: 60,
            "images/ali.jfif",
            fit: BoxFit.cover,
          )
          )
        ),
CircleAvatar(
	backgroundImage: NetworkImage(
	"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2767608770,826089718&fm=26&gp=0.jpg"),
),

引入本地图片配置

flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  assets:
     - images/ali.jfif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值