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
|
import 'package:flutter/material.dart';
import 'package:sense_the_rhythm/arrows.dart';
import 'package:sense_the_rhythm/level.dart';
import 'package:sense_the_rhythm/simfile.dart';
class GameOverStats extends StatelessWidget {
const GameOverStats({super.key, required this.simfile, required this.notes});
final Simfile simfile;
final List<Note> notes;
@override
Widget build(BuildContext context) {
int hits = notes.where((note) => note.wasHit == true).length;
int misses = notes.where((note) => note.wasHit == false).length;
int total = notes.length;
int percent = (hits.toDouble() / total.toDouble() * 100).toInt();
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(Icons.arrow_back)),
title: Text('Game Stats'),
),
body: Center(
child: Column(
children: [
Text(' $percent%',
style: TextStyle(
fontSize: 60,
fontWeight: FontWeight.bold,
color: Colors.orange)),
DataTable(columns: [
DataColumn(label: Container()),
DataColumn(label: Container()),
], rows: [
DataRow(cells: [
DataCell(Text('Hits')),
DataCell(Text(hits.toString())),
]),
DataRow(cells: [
DataCell(Text('Misses')),
DataCell(Text(misses.toString())),
]),
DataRow(cells: [
DataCell(Text('Total')),
DataCell(Text(total.toString())),
]),
]),
TextButton(
onPressed: () {
Route route =
MaterialPageRoute(builder: (context) => Level(simfile));
Navigator.pushReplacement(context, route);
},
child: Text('Retry'))
],
),
),
);
}
}
|