Flutter使用BoxShadow设置投影

class DefaultCardContainer extends StatelessWidget {
  final Color backgroundColor;
  final Widget child;
  final EdgeInsets padding;
  final EdgeInsets margin;
  DefaultCardContainer({
    this.backgroundColor=Colors.white,
    this.child,
    this.padding,
    this.margin
  });
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      margin: margin,
      decoration: BoxDecoration(
        color: backgroundColor,
        borderRadius: BorderRadius.circular(Sizes(16).width()),
        boxShadow: [
          BoxShadow(
            offset: Offset(2, 1),//x,y轴
            color: Colour.SHADOW_COLOR,//投影颜色
            blurRadius: Sizes(12).width()//投影距离
          )
        ]
      ),
      child: child,
    );
  }
}

你可能感兴趣的:(Flutter)