我不能创建Flutter Flutter 中的头像,因为图像小工具的背景是动态的或视频的,所以我try 使用头像作为蓝图,然后用API中新的动态图像进行剪辑.

以下是我的代码:

Container(
            height: height,
            width: width,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(
                  Radius.elliptical(width / 3 * 1.4, width / 3 * 1.6),
                ),
                // color: mainColor,
                image: decorationImage ??
                    DecorationImage(image: AssetImage(unknown_person))),
            child: child ?? SizedBox(),
          );

这是我想要的,没有黑色边框.

enter image description here enter image description here

这就是我得到的:

enter image description here

推荐答案

使用clipBehaviour属性的Container,根据需要 for each 角落分配半径,如下所示

Container(
    clipBehavior: Clip.antiAlias,
    height: 100,
    width: 100,
    decoration: BoxDecoration(
// give radius to each corner different
      color: Colors.black,
      borderRadius: BorderRadius.only(
        topLeft: Radius.circular(40),
        topRight: Radius.circular(20),
        bottomLeft: Radius.circular(20),
        bottomRight: Radius.circular(50),
      ),
    ),
    child: Image.asset(
      'assets/images/stripe.png',
      fit: BoxFit.cover,
      height: 100,
      width: 100,
    ),
  )

这就是你将得到的

enter image description here

Ios相关问答推荐

如何在HStack中将sfsymbol与Text视图对齐?

分配给指针会通过 class_addMethod 导致 EXC_BAD_ACCESS

BezierPath 中绘制图像形状轮廓的算法(Canny 边缘检测器)

确保方法调配的安全有效实施

在 Swift 中,对象如何被准确地从内存中移除?

SwiftUI HStack 文本字段对齐

Flutter动画放大图

在我的 M1 上出现 Architecture arm64 问题,因此我无法运行我的旧项目

如何在 SwiftUI 中创建两个大小相同的正方形占据整个屏幕宽度?

如何在swiftui中更改可搜索的搜索图标 colored颜色

将值传递给导航链接视图中的文本框

如何将单个按钮传递到自定义 ConfirmationDialog

JSONDecoder 在模拟器上运行良好时无法在真实设备上解码

async/await、Task 和 [weak self]

CocoaPods 找不到 podFirebase/Core的兼容版本 | cloud_firestore, Flutter

在 iOS 中获取设备位置(仅限国家/地区)

水平滚动 UICollectionView 时对齐单元格的中心

如何为 UILabel 的背景 colored颜色 设置动画?

UITableView 中的圆形 UIImageView 没有性能影响?

将 struct 保存到 UserDefaults