mocart2

Untitled

Aug 17th, 2020 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.45 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:quiz/models/Questions.dart';
  3. import 'package:quiz/widgets/answer.dart';
  4.  
  5. class HomePage extends StatefulWidget {
  6.   @override
  7.   _HomePageState createState() => _HomePageState();
  8. }
  9.  
  10. class _HomePageState extends State<HomePage> {
  11.   final QuestionData data = QuestionData();
  12.  
  13.   Widget build(BuildContext context) {
  14.     int _countResult = 0;
  15.     int _questionIndex = 0;
  16.     return Scaffold(
  17.         appBar: AppBar(title: Text('QUIZ')),
  18.         body: Container(
  19.           constraints: BoxConstraints.expand(),
  20.           decoration: BoxDecoration(
  21.               color: const Color(0xff2a375a),
  22.               image: DecorationImage(
  23.                 image: AssetImage('assets/images/bg.png'),
  24.                 fit: BoxFit.cover,
  25.               )),
  26.           child: Column(
  27.             children: <Widget>[
  28.               Container(
  29.                 padding: const EdgeInsets.all(10.0),
  30.                 child: Text(data.questions[_questionIndex].title,
  31.                     style: Theme.of(context).textTheme.caption),
  32.               ),
  33.               ...data.questions[_questionIndex].answers.map(
  34.                 (value) => Answer(title: value['answer'],)
  35.                 ).toList(),
  36.               RaisedButton(
  37.                 onPressed: () =>
  38.                 setState(() => _questionIndex++),
  39.                 child: Text('Next'),
  40.               ),
  41.             ],
  42.           ),
  43.         ));
  44.   }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment