-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
tween_animation_builder.dart
81 lines (74 loc) · 2.38 KB
/
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
71
72
73
74
75
76
77
78
79
80
81
import 'package:flutter/material.dart';
import 'package:flutter_widget_guide/utils.dart';
import '../Ads.dart';
import '../Code.dart';
import '../CodeScreen.dart';
class TweenAnimationBuilderWidget extends StatefulWidget {
@override
_TweenAnimationBuilderWidgetState createState() =>
_TweenAnimationBuilderWidgetState();
}
class _TweenAnimationBuilderWidgetState
extends State<TweenAnimationBuilderWidget> {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
@override
void initState() {
//Hide banner ad if it isn't already hidden
Ads.hideBannerAd();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
centerTitle: true,
title: Text(
'TweenAnimationBuilder Widget',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
fontFamily: Utils.ubuntuRegularFont),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.code),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CodeScreen(code: Code.tweenAnimationBuilderWidgetCode),
),
),
)
],
),
body: Center(
child: TweenAnimationBuilder<Color>(
duration: const Duration(seconds: 3),
///Values for the Animation
///Type of tween (here: Color) should match the second parameter
///of the builder and the Class type parameter(if specified)
tween: ColorTween(begin: Colors.yellow, end: Colors.purple),
/// Added child here as a performance optimization. Just so that
/// flutter does not build the entire widget tree during the animation
child: FlutterLogo(
size: 200,
colors: Colors.yellow,
),
builder: (BuildContext _, Color value, Widget child) {
return ColorFiltered(
child: child,
colorFilter: ColorFilter.mode(value, BlendMode.modulate),
);
},
onEnd: () => _scaffoldKey.currentState.showSnackBar(
SnackBar(
content: Text("Done with the Animation"),
duration: Duration(milliseconds: 3000),
),
),
),
),
);
}
}