This is a class UniqueId which is a valueobject. This is for checking equality and all that
class UniqueId extends ValueObject<String> {
@override
final Either<ValueFailure<String>, String> value;
factory UniqueId() {
return UniqueId._(
Right(const Uuid().v1())
);
}
factory UniqueId.fromUniqueString(String uniqueId) {
return UniqueId._(Right(uniqueId));
}
const UniqueId._(
this.value,
);
}
Then I have used freezed.
@freezed
abstract class User1 with _$User1{
const factory User1(
{required UniqueId id,}
) = _User1;
}
Now I am giving the part I am having problem with
@LazySingleton(as: IauthFailure)
class FirebaseAuthFailure implements IauthFailure {
final FirebaseAuth firebaseAuth;
final GoogleSignIn googleSignIn;
FirebaseAuthFailure(this.firebaseAuth, this.googleSignIn);
@override
Future<Option<User1>> getSignedInUser() =>
firebaseAuth.currentUser().then((firebaseUser) =>
optionOf(firebaseUser?.toDomain()));
The error I am getting is given below:
error1: The function can’t be unconditionally invoked because it can be ‘null’.
solution I used:
@override
Future<Option<User1>> getSignedInUser() =>
firebaseAuth.currentUser!().then((firebaseUser) => optionOf(firebaseUser?.toDomain()));
error2:the expression doesn’t evaluate to a function, so it can’t be invoked.
solution I used:
@override
Future<Option<User1>> getSignedInUser() =>
firebaseAuth.currentUser!.then((firebaseUser) => optionOf(firebaseUser?.toDomain()));
error3:The method ‘then’ isn’t defined for the type ‘User’.
Try correcting the name to the name of an existing method, or defining a method named ‘then’.
solution I used: Cannot find a solution
The definition of toDomain()
is :
extension FirebaseUserDomainX on User {
User1 toDomain() {
return User1(id: UniqueId.fromUniqueString(uid));
}
}
Actually I am not getting this toDomain
when I am hovering over it and click go to definition its saying no defintion.
2
Answers
If i understood it correctly (your question is not very clear), you should update your code accordingly to deprecated methods.
currentUser is not a method anymore, but it is a getter.
also I’m assuming
_firebaseAuth
is an instance ofFirebaseAuth
It would be very valuable if you posted the error that you’re getting when using
optionOf
I have found the error of it.
see this solution and try it.