-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathfade_transition.dart
51 lines (44 loc) · 1.22 KB
/
fade_transition.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:flutter/material.dart';
class MyFadeTransition extends StatefulWidget {
const MyFadeTransition({Key? key}) : super(key: key);
@override
State<MyFadeTransition> createState() => _MyFadeTransitionState();
}
class _MyFadeTransitionState extends State<MyFadeTransition>
with SingleTickerProviderStateMixin {
AnimationController? _controller;
Animation<double>? _animation;
@override
initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,
)..repeat(reverse: true);
_animation = CurvedAnimation(parent: _controller!, curve: Curves.easeIn);
}
@override
void dispose() {
_controller!.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Fade Transition')),
body: Center(
child: FadeTransition(
opacity: _animation!,
child: Container(
height: 200,
width: 200,
decoration: BoxDecoration(
color: Colors.deepPurple[300],
borderRadius: BorderRadius.circular(20),
),
),
),
),
);
}
}