Created
February 9, 2021 05:19
-
-
Save Chico-Chen/e56195b7360251d70e9489ecd00f00c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class Result extends StatelessWidget { | |
final int resultScore; | |
final Function 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, | |
), | |
FlatButton( | |
child: Text( | |
'Restart Quiz!', | |
), | |
textColor: Colors.blue, | |
onPressed: resetHandler, | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment