-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.dart
63 lines (54 loc) · 1.64 KB
/
main.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
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<MyApp> with SingleTickerProviderStateMixin {
/*
* animation typically typically have a sequence of numbers or a list of
* numbers that you are going to modify over time, animation itself is the
* individual number that changes over time
*
* animation controller is the time at which that sequence is changed
* */
Animation<double> animation;
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(
duration: const Duration(milliseconds: 10000), vsync: this);
final CurvedAnimation curve =
CurvedAnimation(parent: controller, curve: Curves.bounceIn);
animation = Tween(begin: 0.0, end: 300.0).animate(curve);
controller.forward();
}
Widget builder(BuildContext context, Widget child) {
return Container(
height: animation.value, width: animation.value, child: FlutterLogo());
}
// we need to dispose our controller once the animation is done otherwise it will chew up the battery and seems your app is hung up
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Name here'),
),
body: Container(
padding: EdgeInsets.all(32.0),
child: Center(
child: AnimatedBuilder(animation: animation, builder: builder),
)),
);
}
}