使用图像作为自定义形状卡片/材料小部件的背景

Ham*_*edi 2 android material-design flutter flutter-layout flutter-widget

有一种ContinuousRectangleBorder油漆,我可以将其传递给CardMaterial小部件的形状参数。

Material(
  shape: ContinuousRectangleBorder(
    borderRadius: BorderRadius.circular(50),
  ),
  elevation: 4,
  color: theme.primaryColor,
  child: image,
  borderOnForeground: true,
)
Run Code Online (Sandbox Code Playgroud)

但是在 android 中,如果我将图像传递给小部件,则图像不会作为父级剪辑。裁剪具有相同形状的图像的最佳方法是什么?

M A*_*tib 5

尝试这个 :

 Material(
  shape: ContinuousRectangleBorder(
    borderRadius: BorderRadius.circular(50),
  ),
  elevation: 4,
  color: theme.primaryColor,
  child: image,
  borderOnForeground: true,
  clipBehavior: Clip.antiAliasWithSaveLayer,
)
Run Code Online (Sandbox Code Playgroud)