Skip to content

Commit 4e71165

Browse files
committed
lesson-16
1 parent d74dd40 commit 4e71165

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ninja_id/lib/main.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ void main() => runApp(MaterialApp(
44
home: NinjaCard(),
55
));
66

7-
class NinjaCard extends StatelessWidget {
7+
class NinjaCard extends StatefulWidget {
8+
@override
9+
_NinjaCardState createState() => _NinjaCardState();
10+
}
11+
12+
class _NinjaCardState extends State<NinjaCard> {
13+
14+
int ninjaLevel = 0;
15+
816
@override
917
Widget build(BuildContext context) {
1018
return Scaffold(
@@ -15,6 +23,15 @@ class NinjaCard extends StatelessWidget {
1523
backgroundColor: Colors.grey[850],
1624
elevation: 0.0,
1725
),
26+
floatingActionButton: FloatingActionButton(
27+
onPressed: () {
28+
setState(() {
29+
ninjaLevel += 1;
30+
});
31+
},
32+
backgroundColor: Colors.grey[800],
33+
child: Icon(Icons.add),
34+
),
1835
body: Padding(
1936
padding: const EdgeInsets.fromLTRB(30.0, 40.0, 30.0, 0),
2037
child: Column(
@@ -75,7 +92,7 @@ class NinjaCard extends StatelessWidget {
7592
),
7693
SizedBox(height: 10.0),
7794
Text(
78-
'8',
95+
'$ninjaLevel',
7996
style: TextStyle(
8097
color: Colors.amberAccent[200],
8198
fontWeight: FontWeight.bold,
@@ -107,3 +124,4 @@ class NinjaCard extends StatelessWidget {
107124
);
108125
}
109126
}
127+

0 commit comments

Comments
 (0)