-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult.dart
46 lines (42 loc) · 1.13 KB
/
result.dart
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
import 'package:flutter/material.dart';
class Result extends StatelessWidget {
final int resultScore;
final VoidCallback resetHandler;
Result(this.resultScore, this.resetHandler);
String get resultPhrase {
String resultText;
if (resultScore <= 8) {
resultText = 'You are awesome and innocent!';
} else if (resultScore <= 12) {
resultText = 'Pretty likeable!';
} else if (resultScore <= 16) {
resultText = 'You are ... strange?!';
} else {
resultText = 'You are so bad!';
}
return resultText;
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: <Widget>[
Text(
resultPhrase,
style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
),
onPressed: () {
resetHandler();
},
child: Text('Restart Quiz'),
)
],
),
);
}
}