kdecoration function

BoxDecoration kdecoration(
  1. Color c1,
  2. Color c2, {
  3. int radius = 0,
  4. int borderWidth = 0,
  5. Color? borderColor,
  6. Color? shadowColor,
  7. double dx = 0,
  8. double dy = 0,
  9. double blurRadius = 0,
  10. double spreadRadius = 0,
})

渐变色背景 c1 颜色 c2 颜色 radius 圆角 borderWidth 边框宽度 borderColor 边框颜色 shadowColor 阴影颜色 dx 阴影x轴偏移量 dy 阴影y轴偏移量 blurRadius 阴影模糊程度 spreadRadius 阴影扩散程度

Implementation

BoxDecoration kdecoration(
  Color c1,
  Color c2, {
  int radius = 0,
  int borderWidth = 0,
  Color? borderColor,
  Color? shadowColor,
  double dx = 0,
  double dy = 0,
  double blurRadius = 0,
  double spreadRadius = 0,
}) {
  return BoxDecoration(
    borderRadius: BorderRadius.all(Radius.circular(radius.r)),
    gradient: LinearGradient(
      colors: [c1, c2],
      begin: Alignment.topCenter,
      end: Alignment.bottomCenter,
    ),
    boxShadow: [
      BoxShadow(
        color: shadowColor ?? Colors.transparent,
        offset: Offset(dx, dy), //阴影xy轴偏移量
        blurRadius: blurRadius, //阴影模糊程度
        spreadRadius: spreadRadius, //阴影扩散程度
      ),
    ],
    border: Border.all(
        width: borderWidth.w, color: borderColor ?? Colors.transparent),
  );
}