Skip to content

Commit c2fa640

Browse files
committed
Stateful widgets taughts
1 parent d4725c8 commit c2fa640

File tree

2 files changed

+86
-20
lines changed

2 files changed

+86
-20
lines changed

assets/images/alex.jpg

3.63 MB
Loading

lib/main.dart

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,101 @@ void main() {
66
));
77
}
88

9-
class Home extends StatelessWidget {
9+
class Home extends StatefulWidget {
10+
@override
11+
_HomeState createState() => _HomeState();
12+
}
13+
14+
class _HomeState extends State<Home> {
15+
int ninjaLevel = 0;
16+
1017
@override
1118
Widget build(BuildContext context) {
1219
return Scaffold(
1320
appBar: AppBar(
14-
title: Text('My second application'),
21+
backgroundColor: Colors.grey[800],
22+
title: Text('Ninja ID'),
1523
centerTitle: true,
1624
),
17-
body: Column(
18-
children: [
19-
Text('Row your boat'),
20-
FlatButton(
21-
onPressed: () {},
22-
child: Text('Click it!'),
23-
color: Colors.orange,
25+
body: Container(
26+
color: Colors.grey[900],
27+
child: Padding(
28+
padding: const EdgeInsets.symmetric(
29+
horizontal: 20.0,
30+
vertical: 0.0,
31+
),
32+
child: Column(
33+
crossAxisAlignment: CrossAxisAlignment.start,
34+
mainAxisAlignment: MainAxisAlignment.start,
35+
children: [
36+
SizedBox(
37+
height: 30.0,
38+
),
39+
Center(
40+
child: CircleAvatar(
41+
radius: 40.0,
42+
backgroundImage: AssetImage('assets/images/alex.jpg'),
43+
),
44+
),
45+
Divider(
46+
height: 40.0,
47+
color: Colors.blue,
48+
),
49+
Text(
50+
'NAME',
51+
style: TextStyle(fontSize: 15.0, color: Colors.grey[350]),
52+
),
53+
Text(
54+
'Chun-Li',
55+
style: TextStyle(
56+
fontWeight: FontWeight.bold,
57+
color: Colors.yellow,
58+
fontSize: 35.0),
59+
),
60+
SizedBox(
61+
height: 20.0,
62+
),
63+
Text(
64+
'CURRENT NINJA LEVEL',
65+
style: TextStyle(fontSize: 15.0, color: Colors.grey[350]),
66+
),
67+
Text(
68+
'$ninjaLevel',
69+
style: TextStyle(
70+
fontWeight: FontWeight.bold,
71+
color: Colors.yellow,
72+
fontSize: 35.0),
73+
),
74+
SizedBox(
75+
height: 20.0,
76+
),
77+
Row(children: [
78+
Icon(
79+
Icons.email,
80+
color: Colors.grey[300],
81+
),
82+
SizedBox(
83+
width: 10.0,
84+
),
85+
Text(
86+
'chun-li@ninja.com',
87+
style: TextStyle(
88+
color: Colors.grey[300],
89+
),
90+
)
91+
]),
92+
],
2493
),
25-
Container(
26-
color: Colors.cyan,
27-
padding: EdgeInsets.all(30.0),
28-
child: Text('Encapsulated'),
29-
)
30-
],
31-
mainAxisAlignment: MainAxisAlignment.center,
32-
crossAxisAlignment: CrossAxisAlignment.stretch,
94+
),
3395
),
3496
floatingActionButton: FloatingActionButton(
35-
child: Text('Click'),
36-
onPressed: () {},
37-
backgroundColor: Colors.teal[200],
97+
onPressed: () {
98+
setState(() {
99+
ninjaLevel++;
100+
});
101+
},
102+
child: Icon(Icons.add),
103+
backgroundColor: Colors.yellow,
38104
),
39105
);
40106
}

0 commit comments

Comments
 (0)