微信交流群

老孟公众号

# PhysicalModel

代表物理层的控件,将其子控件裁剪为一个形状,可以设置阴影值及颜色,用法如下:

PhysicalModel(
  borderRadius: BorderRadius.circular(20),
  color: Colors.blue,
  elevation: 8,
  child: Container(
    height: 100,
    width: 100,
  ),
)
1
2
3
4
5
6
7
8
9

效果如下:

设置阴影值及颜色:

PhysicalModel(
  borderRadius: BorderRadius.circular(20),
  color: Colors.blue,
  elevation: 18,
  shadowColor: Colors.red,
  child: Container(
    height: 100,
    width: 100,
  ),
)
1
2
3
4
5
6
7
8
9
10

效果如下:

# PhysicalShape

PhysicalShape 与PhysicalModel类似,其提供阴影

PhysicalShape({
    Key key,
    @required this.clipper,设置边缘剪切形状
    this.clipBehavior = Clip.none,
    this.elevation = 0.0,设置垂直高度
    @required this.color,背景颜色
    this.shadowColor = const Color(0xFF000000),影子颜色
    Widget child,
  })
1
2
3
4
5
6
7
8
9

PhysicalShape和PhysicalModel类似,只不过可以自定义path,下面裁剪为圆形:

PhysicalShape(
  color: Colors.red,
  clipper: ShapeBorderClipper(shape: CircleBorder()),
  child: Container(
    height: 150,
    width: 150,
  ),
)
1
2
3
4
5
6
7
8

image-20200513183150420

本文由Rock提供。