This is the flutter code that I wrote 2 years ago. But I couldn't make any sense of why it has stopped working now.
How do I fix this exception.
import './question.dart';
import './answer.dart';
class Quiz extends StatelessWidget {
final List<Map<String, dynamic>> questions;
final int questionIndex;
final Function answerQuestion;
const Quiz({
super.key,
required this.questions,
required this.answerQuestion,
required this.questionIndex,
});
@override
Widget build(BuildContext context) {
return Column(
children: [
Question(
questions[questionIndex]['questionText'] as String,
),
...(questions[questionIndex]['answers'] as List<Map<String, dynamic>?>)
.map((answer) {
return Answer(
() => answerQuestion(answer['score']), answer!['text'] as String);
}).toList()
],
);
}
}
