Stream Provider
Update the main.dart
file to wrap the MaterialApp
with a StreamProvider
widget. It will listen to the Firestore document and update the widget tree when the document’s data changes.
main.dart
// ...
import 'package:provider/provider.dart';
import 'package:quizapp/services/services.dart';
// ...
return StreamProvider(
create: (_) => FirestoreService().streamReport(),
initialData: Report(),
child: MaterialApp(
// ..
),
);