Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:quiz/models/Questions.dart';
- import 'package:quiz/widgets/answer.dart';
- class HomePage extends StatefulWidget {
- @override
- _HomePageState createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- final QuestionData data = QuestionData();
- Widget build(BuildContext context) {
- int _countResult = 0;
- int _questionIndex = 0;
- return Scaffold(
- appBar: AppBar(title: Text('QUIZ')),
- body: Container(
- constraints: BoxConstraints.expand(),
- decoration: BoxDecoration(
- color: const Color(0xff2a375a),
- image: DecorationImage(
- image: AssetImage('assets/images/bg.png'),
- fit: BoxFit.cover,
- )),
- child: Column(
- children: <Widget>[
- Container(
- padding: const EdgeInsets.all(10.0),
- child: Text(data.questions[_questionIndex].title,
- style: Theme.of(context).textTheme.caption),
- ),
- ...data.questions[_questionIndex].answers.map(
- (value) => Answer(title: value['answer'],)
- ).toList(),
- RaisedButton(
- onPressed: () =>
- setState(() => _questionIndex++),
- child: Text('Next'),
- ),
- ],
- ),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment