// Author: fengshengxiong
// Date: 2024/5/29
// Description: 圆形缺口裁剪

import 'package:flutter/material.dart';

class CircularNotchClipper extends CustomClipper<Path> {
  final double notchRadius;

  CircularNotchClipper({required this.notchRadius});

  @override
  Path getClip(Size size) {
    final Path path = Path()
      ..lineTo(size.width, 0)
      ..lineTo(size.width, size.height - notchRadius - 2.5)
      ..arcToPoint(
        Offset(size.width - notchRadius - 2.5, size.height),
        radius: Radius.circular(notchRadius - 2.5),
        clockwise: false,
      )
      ..lineTo(0, size.height)
      ..lineTo(0, 0)
      ..close();
    return path;
  }

  @override
  bool shouldReclip(CircularNotchClipper oldClipper) {
    return oldClipper.notchRadius != notchRadius;
  }
}