drawShadow method

void drawShadow(
  1. Canvas canvas,
  2. Size size,
  3. Rect rect
)

Draws a shadow around the checkbox to provide visual depth

Implementation

void drawShadow(Canvas canvas, Size size, Rect rect) {
  /// Define the path for the rounded square
  Path squarePath = Path()
    ..addRRect(RRect.fromRectAndRadius(rect, const Radius.circular(4)));

  /// Restrict the shadow painting to the checkbox area
  canvas.clipPath(squarePath);

  /// Create a Paint object for the shadow
  Paint shadowPaint = Paint();

  /// Offset the shadow based on the theme
  Offset shadowOffset = const Offset(0, 0);
  if (isLightTheme) {
    shadowOffset = const Offset(0, -10);
    shadowPaint = Paint()
      ..color = CDKTheme.black.withOpacity(0.25)
      ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 10);
  } else {
    shadowOffset = const Offset(0, -8);
    shadowPaint = Paint()
      ..color = CDKTheme.black.withOpacity(0.5)
      ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 6);
  }

  // Draw shadow
  canvas.drawRRect(
      RRect.fromRectAndRadius(
          rect.shift(shadowOffset), const Radius.circular(4)),
      shadowPaint);

  // Restore drawing clip
  canvas.clipRect(Rect.fromLTWH(0, 0, size.width, size.height));
}