- The argument type 'User Function(User)' can't be assigned to the parameter type 'User Function(User?)'.
- A value of type 'User?' can't be returned from the method '_userFromFirebaseUser' because it has a return type of 'User'.
CodePudding user response:
Since you might return null
from your function, you need to declare your function that null
is possible, so instead of:
User _userFromFirebaseUser(auth.User user) {
...
}
You have to write it like this:
User? _userFromFirebaseUser(auth.User user) {
...
}
Mind the question mark - this essentially means, that this function will either return your User
object or null
, without the question mark, it always has to be an instance of User
CodePudding user response:
I assume you want _userFromFirebaseUser
to return your User
model, not auth.User
, right?
User _userFromFirebaseUser(auth.User user) {
return User(uid: user.uid);
}