Untitled
unknown
plain_text
2 years ago
2.1 kB
5
Indexable
import 'package:flutter/material.dart';
import 'package:quizapp/questionlist.dart';
class Question extends StatefulWidget {
const Question({super.key});
@override
State<Question> createState() => _QuestionStateState();
}
class _QuestionStateState extends State<Question> {
List _questions=[
Quiz(qus: 'You are interested in technology',ans: true),
Quiz(qus: 'Your college gives you motivation',ans: true),
Quiz(qus: 'IT field has limited job opportunities',ans: false),
Quiz(qus: 'Android is better than IOS',ans: true),
Quiz(qus: 'India has a well developed IT sector',ans: true),
Quiz(qus: 'Mobile phones are addictive',ans: true),
Quiz(qus: 'Coding always interests you',ans: false),
Quiz(qus: 'Apple computers are better than PC',ans: false),
];
int index= 0;
int count=0;
int _qusNo=0;
void next_question(){
if(_qusNo< _questions.length ) {
setState(() {
_qusNo++;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlueAccent,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_questions[_qusNo].qus,
style: TextStyle(fontSize: 25,color: Colors.black),
),
SizedBox(
height:200,
),
Container(height:40,width:200,
color: Colors.lightGreenAccent,child:
TextButton(onPressed:(){next_question();}, child: Text('true',
style: TextStyle(color: Colors.black, fontSize: 25)))),
SizedBox(
height:50,
),
Container(height:40,width:200,color: Colors.lightGreenAccent,child: TextButton(onPressed:(){next_question();}, child: Text('false',
style: TextStyle(color: Colors.black, fontSize: 25)))),
]),
));
}
}
Editor is loading...
Leave a Comment