Skip to content

Instantly share code, notes, and snippets.

@Chico-Chen
Created February 9, 2021 05:19
Show Gist options
  • Save Chico-Chen/e56195b7360251d70e9489ecd00f00c1 to your computer and use it in GitHub Desktop.
Save Chico-Chen/e56195b7360251d70e9489ecd00f00c1 to your computer and use it in GitHub Desktop.
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