I'm trying to navigate to another screen from first one , so basically i'm checking if user is logged in or not and based on that i navigate or not to the next screen , but i'm getting an error of a context while trying that
FirebaseAuth.instance
.authStateChanges()
.listen((event) {
if(event == null){
// User is null
} else {
// here i navigate to next screen
Navigator.push(context,
MaterialPageRoute(builder: (context) => new MainScreen()));
}
});
} ```
* I'm calling the code at first to check for user logging state
@override
void didChangeDependencies() {
_AuthenticateUser(context);
super.didChangeDependencies();
}
* This is the error i'm getting
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.```
question from:
https://stackoverflow.com/questions/65846408/the-context-used-to-push-or-pop-routes-from-the-navigator-must-be-that-of-a-widg 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…