File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ class BlobAnimator {
55 AnimationController animationController;
66 List <List <Tween >> tweens = [];
77 List <List <Animation >> anims = [];
8+ final Curve ? animationCurve;
89
9- BlobAnimator ({required this .pathPoints, required this .animationController});
10+ BlobAnimator ({required this .pathPoints, required this .animationController, this .animationCurve = Curves .linear });
1011
1112 init (Function (List <Offset >) callback) {
1213 Animation <double > animation = CurvedAnimation (
1314 parent: animationController,
14- curve: Curves .linear ,
15+ curve: animationCurve ! ,
1516 );
1617 pathPoints.asMap ().forEach ((i, p) {
1718 tweens.insert (i, []);
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class AnimatedBlob extends StatefulWidget {
1515 final Duration ? duration;
1616 final BlobData ? fromBlobData;
1717 final BlobData toBlobData;
18+ final Curve ? animationCurve;
1819
1920 const AnimatedBlob ({
2021 this .size = 200 ,
@@ -26,6 +27,7 @@ class AnimatedBlob extends StatefulWidget {
2627 this .id,
2728 this .duration,
2829 this .child,
30+ this .animationCurve
2931 });
3032
3133 @override
@@ -51,7 +53,8 @@ class _AnimatedBlobState extends State<AnimatedBlob>
5153 AnimationController (duration: widget.duration, vsync: this );
5254 animator = BlobAnimator (
5355 animationController: _animationController,
54- pathPoints: widget.toBlobData.points! .destPoints! );
56+ pathPoints: widget.toBlobData.points! .destPoints! ,
57+ animationCurve: widget.animationCurve);
5558 animator.init ((o) {
5659 setState (() {
5760 data = BlobGenerator (
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class Blob extends StatefulWidget {
2020 final Duration ? duration;
2121 final bool loop;
2222 final bool isAnimated;
23+ final Curve ? animationCurve;
2324
2425 static int count = 0 ;
2526
@@ -34,7 +35,8 @@ class Blob extends StatefulWidget {
3435 }) : loop = false ,
3536 id = null ,
3637 duration = null ,
37- isAnimated = false ;
38+ isAnimated = false ,
39+ animationCurve = null ;
3840 Blob .animatedRandom ({
3941 required this .size,
4042 this .edgesCount = BlobConfig .edgesCount,
@@ -47,6 +49,7 @@ class Blob extends StatefulWidget {
4749 this .loop = false ,
4850 this .controller,
4951 this .child,
52+ this .animationCurve = Curves .easeInOutCubic,
5053 }) : isAnimated = true ,
5154 id = null ;
5255
@@ -61,7 +64,8 @@ class Blob extends StatefulWidget {
6164 edgesCount = null ,
6265 minGrowth = null ,
6366 duration = null ,
64- isAnimated = false ;
67+ isAnimated = false ,
68+ animationCurve = null ;
6569
6670 Blob .animatedFromID ({
6771 required this .id,
@@ -74,6 +78,7 @@ class Blob extends StatefulWidget {
7478 this .loop = false ,
7579 this .controller,
7680 this .child,
81+ this .animationCurve = Curves .easeInOutCubic,
7782 }) : isAnimated = true ,
7883 edgesCount = null ,
7984 minGrowth = null ;
@@ -136,6 +141,7 @@ class _BlobState extends State<Blob> {
136141 debug: widget.debug,
137142 duration: widget.duration,
138143 child: widget.child,
144+ animationCurve: widget.animationCurve,
139145 );
140146 }
141147
You can’t perform that action at this time.
0 commit comments