Line data Source code
1 : import 'dart:ui';
2 :
3 : import 'package:flutter/material.dart';
4 :
5 : @immutable
6 : class CircularRevealClipper extends CustomClipper<Path> {
7 : final double fraction;
8 : final Alignment? centerAlignment;
9 : final Offset centerOffset;
10 : final double? minRadius;
11 : final double maxRadius;
12 :
13 2 : const CircularRevealClipper({
14 : required this.fraction,
15 : required this.centerOffset,
16 : this.centerAlignment,
17 : this.minRadius,
18 : required this.maxRadius,
19 : });
20 :
21 2 : @override
22 : Path getClip(Size size) {
23 : final Offset center =
24 4 : centerAlignment?.alongSize(size) ?? centerOffset;
25 2 : final minRadius = this.minRadius ?? 0;
26 2 : final maxRadius = this.maxRadius;
27 :
28 2 : return Path()
29 2 : ..addOval(
30 2 : Rect.fromCircle(
31 : center: center,
32 4 : radius: lerpDouble(minRadius, maxRadius, fraction)!,
33 : ),
34 : );
35 : }
36 :
37 2 : @override
38 : bool shouldReclip(CustomClipper<Path> oldClipper) => true;
39 : }
|