You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I cant find a way to add a provider based on the value of a stream (in this case, the value of a firebase auth).
Describe the solution you'd like
Take this from provider package. This widgets sits on top of MaterialApp and get a builder which in fact is the whole app. So its a way to "inject" providers (here a firestore db provider with a valid connection based on user credentials) after a successful login.
class AuthWidgetBuilder extends StatelessWidget {
const AuthWidgetBuilder({Key key, @required this.builder}) : super(key: key);
final Widget Function(BuildContext, AsyncSnapshot<User>) builder;
@override
Widget build(BuildContext context) {
final authService = Provider.of<AuthService>(context, listen: false);
return StreamBuilder<User>(
stream: authService.onAuthStateChanged,
builder: (BuildContext context, AsyncSnapshot<User> snapshot) {
final User user = snapshot.data;
if (user != null) {
return MultiProvider(
providers: <SingleChildCloneableWidget>[
Provider<User>.value(value: user),
ProxyProvider<User, FirestoreDatabase>(
update: (_, User user, __) => FirestoreDatabase(uid: user.uid),
)
],
child: builder(context, snapshot),
);
}
return builder(context, snapshot);
},
);
}
}
Additional context
I think "emulating" ProxyProvider in Riverpod should be quite easy with the "ref" variable but the whole concept of conditional providers is not clear. Perhaps i am missing something very basic here.
The text was updated successfully, but these errors were encountered:
final auth =Provider((ref) =>AuthService());
final user =StreamProvider((ref) async* {
awaitfor (final user in ref.read(auth).onAuthStateChanged) {
yield user;
}
});
final db =StreamProvider((ref) async* {
awaitfor (final user in ref.read(user)) {
yieldFirestoreDatabase(uid: user.uid);
}
});
Is your feature request related to a problem? Please describe.
I cant find a way to add a provider based on the value of a stream (in this case, the value of a firebase auth).
Describe the solution you'd like
Take this from provider package. This widgets sits on top of MaterialApp and get a builder which in fact is the whole app. So its a way to "inject" providers (here a firestore db provider with a valid connection based on user credentials) after a successful login.
Additional context
I think "emulating" ProxyProvider in Riverpod should be quite easy with the "ref" variable but the whole concept of conditional providers is not clear. Perhaps i am missing something very basic here.
The text was updated successfully, but these errors were encountered: