1+ import 'dart:math' ;
2+
13import 'package:flutter/material.dart' ;
24import 'package:hyper_effects/hyper_effects.dart' ;
35
@@ -9,88 +11,177 @@ class SuccessCardAnimation extends StatefulWidget {
911}
1012
1113class _SuccessCardAnimationState extends State <SuccessCardAnimation > {
12- bool isCompleted = true ;
14+ bool isCompleted = false ;
1315
1416 @override
1517 Widget build (BuildContext context) {
16- return ConstrainedBox (
17- constraints: const BoxConstraints (
18- maxWidth: 350 ,
19- maxHeight: 200 ,
20- ),
21- child: MouseRegion (
22- cursor: SystemMouseCursors .click,
23- child: GestureDetector (
24- onTap: () {
25- setState (() {
26- isCompleted = ! isCompleted;
27- });
28- },
29- child: Padding (
30- padding: const EdgeInsets .all (12 ),
31- child: Container (
32- constraints: const BoxConstraints (minHeight: 148 ),
33- decoration: BoxDecoration (
34- color: Colors .white,
35- borderRadius: BorderRadius .circular (16 ),
36- ),
37- child: ClipRRect (
38- borderRadius: BorderRadius .circular (16 ),
39- child: Stack (
40- alignment: Alignment .center,
41- fit: StackFit .expand,
42- children: [
43- Image .asset (
44- 'assets/fashion/fashion_0.jpg' ,
45- fit: BoxFit .cover,
46- ),
47- Positioned .fill (
48- child: Container (
49- decoration: const BoxDecoration (
50- color: Color (0x3A079455 ),
18+ return Column (
19+ mainAxisSize: MainAxisSize .min,
20+ mainAxisAlignment: MainAxisAlignment .center,
21+ children: [
22+ ConstrainedBox (
23+ constraints: const BoxConstraints (
24+ maxWidth: 350 ,
25+ maxHeight: 200 ,
26+ ),
27+ child: MouseRegion (
28+ cursor: SystemMouseCursors .click,
29+ child: GestureDetector (
30+ onTap: () {
31+ setState (() {
32+ isCompleted = ! isCompleted;
33+ });
34+ },
35+ child: Padding (
36+ padding: const EdgeInsets .all (12 ),
37+ child: Container (
38+ constraints: const BoxConstraints (minHeight: 148 ),
39+ decoration: BoxDecoration (
40+ color: Colors .white,
41+ borderRadius: BorderRadius .circular (16 ),
42+ ),
43+ child: ClipRRect (
44+ borderRadius: BorderRadius .circular (16 ),
45+ child: Stack (
46+ alignment: Alignment .center,
47+ fit: StackFit .expand,
48+ children: [
49+ Image .asset (
50+ 'assets/fashion/fashion_0.jpg' ,
51+ fit: BoxFit .cover,
5152 ),
52- alignment: Alignment .center,
53- child: const Icon (
54- Icons .check_circle,
55- size: 74 ,
56- )
57- .translateY (
58- isCompleted ? 0 : 100 ,
59- from: isCompleted ? 100 : 0 ,
60- )
61- .animate (
62- trigger: isCompleted,
63- startState:
64- AnimationStartState .useCurrentValues,
65- curve: ! isCompleted
66- ? Curves .easeInBack
67- : Curves .easeOutBack,
68- duration: const Duration (
69- milliseconds: 400 ,
70- ),
53+ Positioned .fill (
54+ child: Container (
55+ decoration: const BoxDecoration (
56+ color: Color (0x3A079455 ),
7157 ),
72- )
73- .opacity (
74- isCompleted ? 1 : 0 ,
75- from: isCompleted ? 0 : 1 ,
58+ alignment: Alignment .center,
59+ child: const Icon (
60+ Icons .check_circle,
61+ size: 74 ,
62+ )
63+ .translateY (
64+ isCompleted ? 0 : 100 ,
65+ from: isCompleted ? 100 : 0 ,
66+ )
67+ .animate (
68+ trigger: isCompleted,
69+ startState:
70+ AnimationStartState .useCurrentValues,
71+ curve: ! isCompleted
72+ ? Curves .easeInBack
73+ : Curves .easeOutBack,
74+ duration: const Duration (
75+ milliseconds: 400 ,
76+ ),
77+ ),
7678 )
77- .animate (
78- trigger: isCompleted,
79- startState:
80- AnimationStartState .useCurrentValues,
81- curve: Curves .easeInOutSine,
82- duration: const Duration (
83- milliseconds: 400 ,
79+ .opacity (
80+ isCompleted ? 1 : 0 ,
81+ from: isCompleted ? 0 : 1 ,
82+ )
83+ .animate (
84+ trigger: isCompleted,
85+ startState:
86+ AnimationStartState .useCurrentValues,
87+ curve: Curves .easeInOutSine,
88+ duration: const Duration (
89+ milliseconds: 400 ,
90+ ),
91+ ),
92+ ),
93+ ],
94+ ),
95+ ),
96+ ),
97+ ),
98+ ),
99+ ),
100+ ),
101+ ConstrainedBox (
102+ constraints: const BoxConstraints (
103+ maxWidth: 350 ,
104+ maxHeight: 200 ,
105+ ),
106+ child: MouseRegion (
107+ cursor: SystemMouseCursors .click,
108+ child: GestureDetector (
109+ onTap: () {
110+ setState (() {
111+ isCompleted = ! isCompleted;
112+ });
113+ },
114+ child: Padding (
115+ padding: const EdgeInsets .all (12 ),
116+ child: Container (
117+ constraints: const BoxConstraints (minHeight: 148 ),
118+ decoration: BoxDecoration (
119+ color: Colors .white,
120+ borderRadius: BorderRadius .circular (16 ),
121+ ),
122+ child: ClipRRect (
123+ borderRadius: BorderRadius .circular (16 ),
124+ child: Stack (
125+ alignment: Alignment .center,
126+ fit: StackFit .expand,
127+ children: [
128+ Image .asset (
129+ 'assets/fashion/fashion_0.jpg' ,
130+ fit: BoxFit .cover,
131+ ),
132+ Positioned .fill (
133+ child: Container (
134+ decoration: const BoxDecoration (
135+ color: Color (0x3A079455 ),
136+ ),
137+ alignment: Alignment .center,
138+ child: const Icon (
139+ Icons .check_circle,
140+ size: 74 ,
141+ )
142+ .scale (isCompleted ? 1.5 : 0 )
143+ .rotate (isCompleted ? 15 * pi / 180 : 0 )
144+ .animate (
145+ trigger: isCompleted,
146+ curve: Curves .easeOutQuart,
147+ duration:
148+ const Duration (milliseconds: 350 ),
149+ )
150+ .scale (
151+ isCompleted ? 1 / 1.5 : 1 ,
152+ )
153+ .rotate (
154+ isCompleted ? - 15 * pi / 180 : 0 ,
155+ )
156+ .animateAfter (
157+ curve: Curves .easeOutBack,
158+ delay: const Duration (milliseconds: 150 ),
159+ duration:
160+ const Duration (milliseconds: 300 ),
161+ ))
162+ // .opacity(
163+ // isCompleted ? 1 : 0,
164+ // from: isCompleted ? 0 : 1,
165+ // )
166+ // .animate(
167+ // trigger: isCompleted,
168+ // startState:
169+ // AnimationStartState.useCurrentValues,
170+ // curve: Curves.easeInOutSine,
171+ // duration: const Duration(
172+ // milliseconds: 400,
173+ // ),
174+ // ),
84175 ),
85- ) ,
176+ ] ,
86177 ),
87- ] ,
178+ ) ,
88179 ),
89180 ),
90181 ),
91182 ),
92183 ),
93- ) ,
184+ ] ,
94185 );
95186 }
96187}
0 commit comments