import 'package:flutter/material.dart';

class MyCard extends StatelessWidget {
  const MyCard({Key key, @required this.child, this.color, this.shadowColor})
      : super(key: key);

  final Widget child;
  final Color color;
  final Color shadowColor;

  @override
  Widget build(BuildContext context) {
    Color _backgroundColor;
    Color _shadowColor;
    if (color == null) {
      _backgroundColor = Colors.white;
    } else {
      _backgroundColor = color;
    }

    if (shadowColor == null) {
      _shadowColor = const Color(0x80DCE7FA);
    } else {
      _shadowColor = shadowColor;
    }

    return Card(
      // margin: EdgeInsets.all(ScreenUtil().setWidth(10)),
      //设置圆角度，也可以不设置有默认值
      shape: RoundedRectangleBorder(
        //形状
        //修改圆角
        borderRadius: BorderRadius.all(Radius.circular(10)),
      ),
      //阴影颜色
      color: color,
      //阴影高度
      elevation: 0.5,
      child: ClipRRect(
          borderRadius: BorderRadius.all(Radius.circular(10)), child: child),
    );

    // DecoratedBox(
    //   decoration: BoxDecoration(
    //       color: _backgroundColor,
    //       borderRadius: BorderRadius.circular(10.0),
    //       boxShadow: [
    //         BoxShadow(color: _shadowColor, offset: Offset(0.0, 2.0), blurRadius: 8.0, spreadRadius: 0.0),
    //       ]
    //   ),
    //   child: child,
    // );
  }
}
