Skip to content

Instantly share code, notes, and snippets.

@Chico-Chen
Created February 9, 2021 04:32
Show Gist options
  • Save Chico-Chen/7d20b856e6b08ee855e4f8f8b153791f to your computer and use it in GitHub Desktop.
Save Chico-Chen/7d20b856e6b08ee855e4f8f8b153791f to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import './question.dart';
import './answer.dart';
class Quiz extends StatelessWidget {
final List<Map<String, Object>> questions;
final int questionIndex;
final Function answerQuestion;
Quiz({
@required this.questions,
@required this.answerQuestion,
@required this.questionIndex,
});
@override
Widget build(BuildContext context) {
return Column(
children: [
Question(
questions[questionIndex]['questionText'],
),
...(questions[questionIndex]['answers'] as List<Map<String, Object>>).map((answer) {
return Answer(() => answerQuestion(answer['score']), answer['text']);
}).toList()
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment