I'm using the provider package. In the root of the widget tree I have a multiprovider:
Widget build(BuildContext context) {
return MultiProvider(
providers: [
StreamProvider<FirebaseUser>.value(
value: FirebaseConnection.getAuthenticationStream()),
StreamProvider<User>.value(
value: FirebaseConnection.getUserStream(uid: ???))
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: LoginScreen.id,
onGenerateRoute: RouteGenerator.generateRoute,
),
);
}
The first StreamProvider provides the logged in user from firebase_auth. The second StreamProvider is supposed to provide additional information to that user (stored in the users collection). The problem is that to get the second stream I need the uid of the FirebaseUser provided with the first stream but I don't know how to access it.
Nesting the StreamProviders didn't work because in the second stream I can only access the (wrong) context of the build method (for Provider.of(context))
FirebaseConnection
a class you made? I can't find it in the firebase documentation. – GrampositiveFutureBuilder
. Once the future completes and the stream is returned, pass it to the provider. – Grampositive