1
+ import 'dart:ui' ;
2
+
1
3
import 'package:flutter/material.dart' ;
4
+
5
+ import 'detailpage.dart' ;
2
6
class HomePage extends StatefulWidget {
3
7
@override
4
8
_HomePageState createState () => _HomePageState ();
5
9
}
6
10
7
- class _HomePageState extends State <HomePage > with SingleTickerProviderStateMixin {
11
+ class _HomePageState extends State <HomePage > with TickerProviderStateMixin {
8
12
AnimationController _controller;
9
13
Animation _animation;
10
- @override
14
+ AnimationController _colorController;
15
+ Animatable <Color > background = TweenSequence <Color >([
16
+ TweenSequenceItem (
17
+ weight: 1.0 ,
18
+ tween: ColorTween (
19
+ begin: Colors .red,
20
+ end: Colors .green,
21
+ ),
22
+ ),
23
+ TweenSequenceItem (
24
+ weight: 1.0 ,
25
+ tween: ColorTween (
26
+ begin: Colors .green,
27
+ end: Colors .blue,
28
+ ),
29
+ ),
30
+ TweenSequenceItem (
31
+ weight: 1.0 ,
32
+ tween: ColorTween (
33
+ begin: Colors .blue,
34
+ end: Colors .pink,
35
+ ),
36
+ ),
37
+ TweenSequenceItem (
38
+ weight: 1.0 ,
39
+ tween: ColorTween (
40
+ begin: Colors .pink,
41
+ end: Colors .red,
42
+ ),
43
+ ),]);
44
+ @override
11
45
void initState () {
12
46
// TODO: implement initState
13
47
super .initState ();
14
48
_controller= AnimationController (vsync: this ,
15
- duration: Duration (milliseconds: 1200 ));
49
+ duration: Duration (milliseconds: 1200 ));
16
50
_animation= CurvedAnimation (parent: _controller, curve: Curves .easeIn);
51
+ setState (() {
52
+ _colorController = AnimationController (vsync: this ,duration: const Duration (seconds: 5 ),)
53
+ ..addListener (() {
54
+ setState (() {
55
+
56
+ });
57
+ })..addStatusListener ((status) {
58
+ if (status == AnimationStatus .completed){
59
+ _colorController.forward (from: 0.0 );
60
+ }
61
+ })..forward ();
62
+ });
17
63
}
18
64
@override
19
65
void dispose () {
@@ -23,13 +69,125 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
23
69
}
24
70
@override
25
71
Widget build (BuildContext context) {
72
+ var textTheme = Theme .of (context).textTheme;
26
73
return Scaffold (
74
+ backgroundColor: Color (0xff242424 ),
27
75
appBar: AppBar (
76
+ backgroundColor: Color (0xff242424 ),
28
77
title: Text ("Animations" ),
29
78
),
30
- body: Center (child: FadeTransition (
31
- opacity: _animation,
32
- child: Image .network ("https://cdn.dribbble.com/users/3281732/screenshots/7421960/media/9dd2e5490681a75e42c7f2c39bfeb905.jpeg" ))),
79
+ body: Column (
80
+ children: [
81
+ Center (child: FadeTransition (
82
+ opacity: _animation,
83
+ child: Padding (
84
+ padding: const EdgeInsets .all (8.0 ),
85
+ child: GestureDetector (
86
+ onTap: () {
87
+ Navigator .push (
88
+ context,
89
+ MaterialPageRoute (
90
+ builder: (context) => HeroDetail ()),
91
+ );
92
+ },
93
+ child: Stack (
94
+ children: [
95
+ Hero (
96
+ tag: "photo" ,
97
+ child: Container (
98
+ height: 340 ,
99
+ width: 567 ,
100
+ decoration: BoxDecoration (
101
+ image: DecorationImage (
102
+ image: AssetImage ("images/joker.jpg" ),
103
+ fit: BoxFit .cover,
104
+ ),
105
+ borderRadius: BorderRadius .circular (11 ),
106
+ ),
107
+ ),
108
+ ),
109
+ Positioned (
110
+ height: 100 ,
111
+ width: 567 ,
112
+ bottom: 0 ,
113
+ child: ClipRRect (
114
+ borderRadius: BorderRadius .only (
115
+ bottomLeft: Radius .circular (11 ),
116
+ bottomRight: Radius .circular (11 ),
117
+ ),
118
+ child: BackdropFilter (
119
+ filter: ImageFilter .blur (
120
+ sigmaX: 16 ,
121
+ sigmaY: 16 ,
122
+ ),
123
+ child: Container (
124
+ color: Colors .grey[600 ].withOpacity (0.5 ),
125
+ ),
126
+ ),
127
+ ),
128
+ ),
129
+ Positioned (
130
+ bottom: 30 ,
131
+ child: Padding (
132
+ padding: const EdgeInsets .all (8.0 ),
133
+ child: Column (
134
+ crossAxisAlignment: CrossAxisAlignment .start,
135
+ children: [
136
+ Text (
137
+ 'JOKER ARRIVES IN FLUTTER WORLD' ,
138
+ style: textTheme.subtitle1.copyWith (
139
+ color: Colors .white,
140
+ fontFamily: 'WorkSans' ,
141
+ fontWeight: FontWeight .w600,
142
+ ),
143
+ ),
144
+ //Ymargin(4),
145
+ Container (
146
+ height: 30 ,
147
+ width: MediaQuery .of (context).size.width,
148
+ child: Text (
149
+
150
+ 'Smile, because it confuses people. Smile, because it’s easier than explaining what is killing you inside. ' ,
151
+ style: textTheme.caption.copyWith (
152
+ color: Colors .white,
153
+ fontFamily: 'WorkSans' ,
154
+ ),
155
+ maxLines: 2 ,
156
+ ),
157
+ ),
158
+ ],
159
+ ),
160
+ ),
161
+ ),
162
+ ],
163
+ ),
164
+ ),
165
+ )
166
+ //Image.network("https://cdn.dribbble.com/users/3281732/screenshots/7421960/media/9dd2e5490681a75e42c7f2c39bfeb905.jpeg")
167
+ )),
168
+ Padding (
169
+ padding: const EdgeInsets .all (10.0 ),
170
+ child: Row (
171
+ children: [
172
+ Container (
173
+ width: 3.5 ,
174
+ height: 22 ,
175
+ color: background.evaluate (AlwaysStoppedAnimation (_colorController.value)),
176
+ ),
177
+ SizedBox (width: 4 ,),
178
+ Text (
179
+ 'DARK SIDE' ,
180
+ style: TextStyle (
181
+ color: Colors .white,
182
+ fontSize: 20 ,
183
+ letterSpacing: 3
184
+ ),
185
+ )
186
+ ],
187
+ ),
188
+ ),
189
+ ],
190
+ ),
33
191
floatingActionButtonLocation:
34
192
FloatingActionButtonLocation .centerFloat,
35
193
floatingActionButton: FloatingActionButton (
@@ -43,3 +201,4 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
43
201
);
44
202
}
45
203
}
204
+
0 commit comments