Skip to content

Instantly share code, notes, and snippets.

@Tawfeekamr
Last active October 24, 2019 11:22
Show Gist options
  • Save Tawfeekamr/572414a1c24aab0bf0e2f16326fc6974 to your computer and use it in GitHub Desktop.
Save Tawfeekamr/572414a1c24aab0bf0e2f16326fc6974 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'question.dart';
void main() => runApp(Quizzler());
class Quizzler extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey.shade900,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: QuizPage(),
),
),
),
);
}
}
class QuizPage extends StatefulWidget {
@override
_QuizPageState createState() => _QuizPageState();
}
class Question {
String questionText;
bool questionAnswer;
Question(String q, bool a){
q = questionText;
a = questionAnswer;
}
}
class _QuizPageState extends State<QuizPage> {
List<Icon> scorekeeper = [];
//
// List<String> questions = [
// 'You can lead a cow down stairs but not up stairs.',
// 'Approximately one quarter of human bones are in the feet.',
// 'A slug\'s blood is green.',
// ];
List<Question> questionsBank = [
Question('You can lead a cow down stairs but not up stairs.', false),
Question('Approximately one quarter of human bones are in the feet.', true),
Question('A slug\'s blood is green.', true),
Question('Buzz Aldrin\'s mother\'s maiden name was \"Moon\".', true),
Question('It is illegal to pee in the Ocean in Portugal.', true),
Question(
'No piece of square dry paper can be folded in half more than 7 times.',
false),
Question(
'In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.',
true),
Question(
'The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.',
false),
Question(
'The total surface area of two human lungs is approximately 70 square metres.',
true),
Question('Google was originally called \"Backrub\".', true),
Question(
'Chocolate affects a dog\'s heart and nervous system; a few ounces are enough to kill a small dog.',
true),
Question(
'In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.',
true),
];
int questionsNumber = 0;
// isNext(questionsNumber) {
// if(questionsNumber < questions.length ) {
// return questionsNumber++;
// }
// }
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex: 5,
child: Padding(
padding: EdgeInsets.all(10.0),
child: Center(
child: Text(
questionsBank[questionsNumber].questionAnswer??'null',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25.0,
color: Colors.white,
),
),
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: FlatButton(
textColor: Colors.white,
color: Colors.green,
child: Text(
'True',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
//The user picked true.
// isNext(questionsNumber);
print(questionsBank[questionsNumber].questionAnswer);
},
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: FlatButton(
color: Colors.red,
child: Text(
'False',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
onPressed: () {
//The user picked false.
// isNext(questionsNumber);
print(questionsNumber);
},
),
),
),
//TODO: Add a Row here as your score keeper
Row(
children: <Widget>[
Icon(
Icons.check
)
],
)
],
);
}
}
/*
question1: 'You can lead a cow down stairs but not up stairs.', false,
question2: 'Approximately one quarter of human bones are in the feet.', true,
question3: 'A slug\'s blood is green.', true,
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment