I have defined all the required arguments. But still getting the below error: 1 positional argument expected by 'AuthStateLoggedOut.new', but 0 found. Try adding the missing argument.
This is my AuthStateLoggedOut Class:
class AuthStateLoggedOut extends AuthState with EquatableMixin{
final Exception? exception;
final bool isLoading;
const AuthStateLoggedOut(Exception? e, {required this.exception, required this.isLoading});
@override
List<Object?> get props => [exception, isLoading];
}
This is my AuthEventInitialize function:
``on<AuthEventInitialize>((event, emit )async{
await provider.initialize();
final user = provider.currentUser;
if(user == null){
emit(const AuthStateLoggedOut(exception: null, isLoading:false,));
} else if(!user.isEmailVerified){
emit(const AuthStateNeedsVerification());
} else{
emit(AuthStateLoggedIn(user));
}
});``
Even if they are nullable, Positional arguments are required by default.
const AuthStateLoggedOut(Exception? e)
e
parameter here, must be passed as an argument when calling that constructor, Although it's nullable but it must be passed.
The only way to achieve that, is making it an optional parameter and keep as nullable.
const AuthStateLoggedOut({Exception? e, required this.exception, required this.isLoading});