drawShadow method

void drawShadow(
  1. Canvas canvas,
  2. Size size,
  3. Offset center,
  4. double radius
)

Implementation

void drawShadow(Canvas canvas, Size size, Offset center, double radius) {
  // Defineix el path per al cercle
  Path circlePath = Path()
    ..addOval(Rect.fromCircle(center: center, radius: radius));

  // Restringeix el dibuix de l'ombra al cercle
  canvas.clipPath(circlePath);

  // Pintura per a l'ombra
  Paint shadowPaint = Paint();
  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);
  }

  // Dibuixar l'ombra
  canvas.drawCircle(center + shadowOffset, radius, shadowPaint);

  // Torna a establir el clip per a dibuixar la resta
  canvas.clipRect(Rect.fromLTWH(0, 0, size.width, size.height));
}