11import 'package:flutter/material.dart' ;
22
33class ScoreCard extends StatelessWidget {
4- const ScoreCard ({super .key, required this .score});
4+ const ScoreCard ({
5+ super .key,
6+ required this .score,
7+ required this .lives,
8+ });
59
610 final ValueNotifier <int > score;
11+ final ValueNotifier <int > lives;
712
813 @override
914 Widget build (BuildContext context) {
1015 return ValueListenableBuilder <int >(
1116 valueListenable: score,
1217 builder: (context, score, child) {
13- return Padding (
14- padding: const EdgeInsets .fromLTRB (12 , 6 , 12 , 18 ),
15- child: Text (
16- 'Score: $score ' .toUpperCase (),
17- style: Theme .of (context).textTheme.titleLarge! ,
18- ),
18+ return ValueListenableBuilder <int >(
19+ valueListenable: lives,
20+ builder: (context, lives, child) {
21+ return Padding (
22+ padding: const EdgeInsets .fromLTRB (12 , 6 , 12 , 18 ),
23+ child: Column (
24+ children: [
25+ Text (
26+ 'Score: $score ' .toUpperCase (),
27+ style: Theme .of (context).textTheme.titleLarge! ,
28+ ),
29+ const SizedBox (height: 10 ),
30+ Row (
31+ mainAxisAlignment: MainAxisAlignment .center,
32+ children: List .generate (
33+ 3 ,
34+ (index) => Padding (
35+ padding: const EdgeInsets .symmetric (horizontal: 5 ),
36+ child: Container (
37+ width: 16 ,
38+ height: 16 ,
39+ decoration: BoxDecoration (
40+ color: index < lives
41+ ? const Color (0xff1e6091 )
42+ : Colors .transparent,
43+ shape: BoxShape .circle,
44+ border: Border .all (
45+ color: const Color (0xff1e6091 ),
46+ width: 2 ,
47+ ),
48+ ),
49+ ),
50+ ),
51+ ),
52+ ),
53+ ],
54+ ),
55+ );
56+ },
1957 );
2058 },
2159 );
2260 }
23- }
61+ }
0 commit comments