👂 Stream Provider

Listen to a realtime Firestore document globally with Provider

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.

file_type_flutter main.dart
// ...
import 'package:provider/provider.dart';
import 'package:quizapp/services/services.dart';

// ...

    return StreamProvider(
            create: (_) => FirestoreService().streamReport(),
            initialData: Report(),
            child: MaterialApp(
                // ..
            ),
          );

Questions? Let's chat

Open Discord