boxDecorationFromDetails function

BoxDecoration? boxDecorationFromDetails({
  1. Color? color,
  2. Border? border,
  3. BoxShape? shape,
  4. BorderRadius? borderRadius,
  5. BlendMode? blendMode,
  6. List<BoxShadow>? boxShadow,
  7. Gradient? gradient,
  8. DecorationImage? image,
})

Implementation

BoxDecoration? boxDecorationFromDetails({
  Color? color,
  Border? border,
  BoxShape? shape,
  BorderRadius? borderRadius,
  BlendMode? blendMode,
  List<BoxShadow>? boxShadow,
  Gradient? gradient,
  DecorationImage? image,
}) {
  bool hasCustomProperties = color != null ||
      border != null ||
      borderRadius != null ||
      gradient != null ||
      shape != null ||
      boxShadow != null ||
      image != null;

  // If no custom properties are provided, return null
  if (!hasCustomProperties) {
    return null;
  }

  return BoxDecoration(
    color: color,
    border: border,
    backgroundBlendMode: color != null || gradient != null ? blendMode : null,
    borderRadius: shape == BoxShape.circle ? null : borderRadius,
    gradient: gradient,
    shape: shape ?? BoxShape.rectangle,
    boxShadow: boxShadow,
    image: image,
  );
}