1

I was initially developing my app with simple change notifier providers. Later I decided to use Firestore and StreamProvider. Now I have a stream that returns a list. I want to populate my list in the Change Notifier after getting data from the Stream Provider. The change notifier has different functions that my widgets are consuming to get different subsets of the central list. That's why I don't want the widgets to consume the stream directly. I want them to consume the Change notifier provider which will be updated by the StreamProvider.

return MultiProvider(
            providers: [
              ChangeNotifierProvider<TodoProvider>(
                  create: (_) => TodoProvider()),
              StreamProvider<List<Todo>>.value(
                  value: new DatabaseServices(
                          FirebaseAuth.instance.currentUser.uid)
                      .getUserTodoList()),
            ],
            child: MaterialApp(
              title: 'Awesome Todo',
              theme: ThemeData(
                primarySwatch: Colors.blue,
                visualDensity: VisualDensity.adaptivePlatformDensity,
              ),
              home: AppNavigationBar(),
            ),
            // child:
            // AppNavigationBar()
          )

Now as you can see, in the multi-provider array I have my change notifier provider and the stream provider. I want to update a list in TodoProvider class when I get an updated list from the DatabaseService.getUserTodoList(). Is a proxy provider useful in this case? Thank you for reading the post. Any help will be greatly appreciated.

Sebastian Gomes
  • 775
  • 9
  • 12
  • 1
    Yes, Proxy provider would be useful in this scenario. [This](https://www.filledstacks.com/post/flutter-provider-v3-architecture/) guide helped me understand the Provider artitecture, check it out. – happy-san Nov 16 '20 at 13:00

0 Answers0