
但是在flutter中,Container并没有这个溢出隐藏的功能,此时,就要借助PhysicalModel实现圆角了,因为PhysicalModel有裁切功能,将超出圆角的部分切掉。先来看下PhysicalModel的构造函数:
PhysicalModel({
//裁剪模式
this.clipBehavior = Clip.none,
//四角圆度半径
this.borderRadius,
//z轴高度
this.elevation = 0.0,
//设置阴影颜色
this.shadowColor = const Color(0xFF000000),
})
使用示例:
class ServiceMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PhysicalModel(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(6)),
// 裁切
clipBehavior: Clip.antiAlias,
elevation: 6.0,
shadowColor: Colors.grey,
child: ...,
);
}
