How can I fix this error: The argument type 'void Function(User)' can't be assigned to the parameter type 'void Function(User?)?'.
instance.authStateChanges().listen((User user) {
if(user == null){
//print('no user');
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => Login()));
}else {
//print('there is a user');
}
});
CodePudding user response:
change the argument user to (User? user)
so the code would be:
instance.authStateChanges().listen((User? user) {
if(user == null){
//print('no user');
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => Login()));
}else {
//print('there is a user');
}
});
CodePudding user response:
Try like this:
instance.authStateChanges().listen((user) {
if(user == null){
//print('no user');
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => Login()));
}else {
//print('there is a user');
}
});