do we need question list in the constructor of QuestionWidget?we can directly access the question list from provider or context inside its build method
import ‘package:flutter/material.dart’;
import ‘package:provider/provider.dart’;
import ‘…/model/question_and_answer_model.dart’;
class QuestionWidget extends StatelessWidget {
const QuestionWidget({
Key key,
@required this.questions,
@required this.counter,
}) : super(key: key);
final List<Map<String, Object>> questions;
final int counter;
@override
Widget build(BuildContext context) {
return Text(
context
.watch()
.questions[context.watch().counter]
[‘question’],
style: TextStyle(
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
);
}
}
Type your question above this line.
Course: https://www.educative.io/collection/10370001/6371585964900352
Lesson: https://www.educative.io/collection/page/10370001/6371585964900352/6552845907656704