-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathday064_tween_animation_builder.dart
70 lines (67 loc) · 2.32 KB
/
day064_tween_animation_builder.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
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day64TweenAnimationBuilder extends StatefulWidget {
Day64TweenAnimationBuilder({Key key}) : super(key: key);
@override
_Day64TweenAnimationBuilderState createState() =>
_Day64TweenAnimationBuilderState();
}
class _Day64TweenAnimationBuilderState
extends State<Day64TweenAnimationBuilder> {
bool repeat = true;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
// ? What is TweenAnimationBuilder....
/**
* ! With the help of TweenAnimationBuilder we can create the custom animation effect to the user....
*/
child: TweenAnimationBuilder<Color>(
tween: repeat
? ColorTween(begin: Colors.red, end: Colors.green)
: ColorTween(
begin: Colors.green,
end: Colors
.red), // ! it required the [tween] property to hold the tween value....
duration: Duration(
seconds: 3), // ! set the [duration] for the animation timing....
curve: Curves
.bounceInOut, // ! set the [curve] for the animation effect....
builder: (context, value, child) => Container(
// ! generate the [builder] to display the ui of the animation....
width: 250,
height: 250,
color: value,
),
onEnd: () {
// ! ues the [onEnd] call back to get the end of the animation....
print("Tween Animation Ends....");
setState(() {
repeat = !repeat;
});
},
),
),
appBar: AppBar(
title: Text('TweenAnimationBuilder'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.help),
onPressed: () async {
const url =
'https://github.com/sanjaysanju618/100-Days-Of-Flutter-Widgets/' +
'blob/master/hundred_days_of_flutter_widget/' +
'lib/day064_tween_animation_builder.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
);
}
}