File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:flutter/material.dart' ;
2
+ import 'package:simple_animations/simple_animations.dart' ;
3
+
4
+ class FadeAnimation extends StatelessWidget {
5
+ final double delay;
6
+ final Widget child;
7
+
8
+ FadeAnimation (this .delay, this .child);
9
+
10
+ @override
11
+ Widget build (BuildContext context) {
12
+ final tween = MultiTrackTween ([
13
+ Track ('opacity' ).add (Duration (milliseconds: 500 ),
14
+ Tween (begin: 0.0 , end: 1.0 )
15
+ ),
16
+ Track ('translateX' ).add (Duration (milliseconds: 500 ),
17
+ Tween (begin: 120.0 , end: 0.0 ),
18
+ curve: Curves .easeOut
19
+ )
20
+ ]);
21
+ return ControlledAnimation (
22
+ delay: Duration (milliseconds: (500 * delay).round ()),
23
+ duration: tween.duration,
24
+ tween: tween,
25
+ child: child,
26
+ builderWithChild: (context, child, animation) => Opacity (
27
+ opacity: animation['opacity' ],
28
+ child: Transform .translate (
29
+ offset: Offset (animation['translateX' ], 0 ),
30
+ child: child,
31
+ ),
32
+ ),
33
+ );
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments