-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathday092_custom_implicit_animations.dart
75 lines (71 loc) · 2.5 KB
/
day092_custom_implicit_animations.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
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day92CustomImplicitAnimations extends StatefulWidget {
Day92CustomImplicitAnimations({Key key}) : super(key: key);
@override
_Day92CustomImplicitAnimationsState createState() =>
_Day92CustomImplicitAnimationsState();
}
class _Day92CustomImplicitAnimationsState
extends State<Day92CustomImplicitAnimations> {
double _sliderValue = 0.0;
Color _newColor = Colors.white;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ! We can create the custom implicit animation for any widget with [TweenAnimationBuilder]....
TweenAnimationBuilder<Color>(
duration: const Duration(seconds: 5),
curve: Curves.elasticOut,
tween: ColorTween(
begin: Colors.white,
end: _newColor,
), // ! if the animation is have final Tween value pls make it final static for performance....
child: Container(
width: 250,
height: 250,
color: Colors.white,
child: FlutterLogo(
size: 250,
),
), // ! always try to add static widgets in [child] for the performance....
builder: (BuildContext context, Color valueColor, Widget child) =>
ColorFiltered(
child: child,
colorFilter: ColorFilter.mode(valueColor, BlendMode.modulate),
),
),
Slider.adaptive(
value: _sliderValue,
onChanged: (value) => setState(() {
_sliderValue = value;
_newColor = Color.lerp(Colors.white, Colors.yellow, _sliderValue);
}),
),
],
),
appBar: AppBar(
title: Text('Custom Implicit Animations'),
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/day092_custom_implicit_animations.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
);
}
}