Imagine there are three screens. main.dart, home.dart & signIn.dart I have the code, shown below. When I'm in the homescreen and the streamProvider(firebaseAuthStateProvider) changes, I will get automatically back to the main.dart screen. After that, the if-query sends me right to the signIn.dart screen. Just like expected. But when I create a new nested screen and the streamProvider changes its value, the "root" screen (home.dart) doesn't send me back to the signIn screen. So I imagine it only works for the first child and not the nested ones.
Is it possible to have just one query to check for a streamProvider in the root screen or do i have to put a query in every single screen to check the value?
class SignInCheck extends ConsumerWidget {
@override
Widget build(BuildContext context, ScopedReader scopedReader) {
final _authState = scopedReader(firebaseAuthStateProvider); //
return _authState.when(data: (value) {
if (value != null) {
return HomeScreen();
} else {
return SignIn();
}
//...