@@ -3,7 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
33
44import '../attach_dialog_widget.dart' ;
55
6- class HighlightMaskAnimation extends StatelessWidget {
6+ class HighlightMaskAnimation extends StatefulWidget {
77 const HighlightMaskAnimation ({
88 Key ? key,
99 required this .controller,
@@ -31,21 +31,43 @@ class HighlightMaskAnimation extends StatelessWidget {
3131
3232 final List <SmartNonAnimationType > nonAnimationTypes;
3333
34+ @override
35+ State <HighlightMaskAnimation > createState () => _HighlightMaskAnimationState ();
36+ }
37+
38+ class _HighlightMaskAnimationState extends State <HighlightMaskAnimation > {
39+ late CurvedAnimation _curvedAnimation;
40+
41+ @override
42+ void initState () {
43+ super .initState ();
44+ _curvedAnimation = CurvedAnimation (
45+ parent: widget.controller,
46+ curve: Curves .linear,
47+ );
48+ }
49+
50+ @override
51+ void dispose () {
52+ _curvedAnimation.dispose ();
53+ super .dispose ();
54+ }
55+
3456 @override
3557 Widget build (BuildContext context) {
3658 //handle mask
3759 late Widget mask;
38- if (usePenetrate) {
60+ if (widget. usePenetrate) {
3961 mask = Container ();
40- } else if (maskWidget != null ) {
41- mask = maskWidget! ;
42- } else if (highlightBuilder == null ) {
43- mask = Container (color: maskColor);
62+ } else if (widget. maskWidget != null ) {
63+ mask = widget. maskWidget! ;
64+ } else if (widget. highlightBuilder == null ) {
65+ mask = Container (color: widget. maskColor);
4466 } else {
4567 mask = ColorFiltered (
4668 colorFilter: ColorFilter .mode (
4769 // mask color
48- maskColor,
70+ widget. maskColor,
4971 BlendMode .srcOut,
5072 ),
5173 child: Stack (children: [
@@ -58,17 +80,17 @@ class HighlightMaskAnimation extends StatelessWidget {
5880 ),
5981
6082 //dissolve mask, highlight location
61- highlightBuilder! .call (targetOffset, targetSize)
83+ widget. highlightBuilder! .call (widget. targetOffset, widget. targetSize)
6284 ]),
6385 );
6486 }
6587
6688 Widget maskAnimation = FadeTransition (
67- opacity: CurvedAnimation (parent : controller, curve : Curves .linear) ,
89+ opacity: _curvedAnimation ,
6890 child: mask,
6991 );
70- if (highlightBuilder != null ) {
71- for (var element in nonAnimationTypes) {
92+ if (widget. highlightBuilder != null ) {
93+ for (var element in widget. nonAnimationTypes) {
7294 if (element == SmartNonAnimationType .highlightMask_nonAnimation) {
7395 maskAnimation = mask;
7496 }
0 commit comments