-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtranslate_animation_screen.dart
80 lines (74 loc) · 2.18 KB
/
translate_animation_screen.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import 'dart:async';
import 'package:flutter/material.dart';
class TranslateAnimationScreen extends StatefulWidget {
const TranslateAnimationScreen({Key? key}) : super(key: key);
@override
_TranslateAnimationScreenState createState() =>
_TranslateAnimationScreenState();
}
class _TranslateAnimationScreenState extends State<TranslateAnimationScreen>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double> _animation;
late Timer _timer;
@override
void initState() {
super.initState();
_animationController =
AnimationController(duration: const Duration(seconds: 3), vsync: this);
_animation = Tween<double>(begin: -1.0, end: 0.0).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut));
_animationController.forward();
// _timer = Timer(const Duration(seconds: 4),
// () => Navigator.pushNamed(context, '/home'));
}
@override
void dispose() {
_animationController.dispose();
_timer.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF5A5A5A),
Color(0xFFA8A8A8),
],
stops: [
0.0,
1.0,
],
),
),
child: Center(
child: AnimatedBuilder(
animation: _animation,
builder: (BuildContext context, Widget? child) {
return Transform.translate(
offset: Offset(
0.0,
_animation.value * (MediaQuery.of(context).size.width / 2),
),
child: child,
);
},
child: const Text(
'My Awesome App',
style: TextStyle(
color: Colors.white,
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
);
}
}