Stream Provider Listen to a realtime Firestore document globally with Provider

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.
Get Unlimited PRO Access

OR


*Enrollment provides full access to this course (and updates) for life.

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?

Ask questions via GitHub below OR chat on Slack #questions