I am trying to log in using firebase using the Google Login in and trying to register a username and account. Basically any authentication process i try to do i get the following error:
Unhandled Exception: type 'List<Object?>' is not a subtype of type 'PigeonUserDetails?' in type cast
Here is the code for my google login in and registering using username and password:
class LoginAccountBloc extends Bloc<LoginAccountEvent, LoginAccountState> {
LoginAccountBloc() : super(LoginAccountInitial()) {
on<LoginAccountSubmitted>(
(event, emit) async {
emit(LoginAccountSubmitting());
try {
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: event.email,
password: event.password,
);
emit(LoginAccountSuccessful());
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
emit(LoginAccountFailure('No user found for that email.'));
} else if (e.code == 'wrong-password') {
emit(LoginAccountFailure('Wrong password provided for that user.'));
} else {
emit(LoginAccountFailure(e.toString()));
}
}
},
);
}
}
class RegisterAccountBloc
extends Bloc<RegisterAccountEvent, RegisterAccountState> {
RegisterAccountBloc() : super(RegisterAccountInitial()) {
on<RegisterAccountSubmitted>(
(event, emit) async {
print(event.username);
print(event.email);
print(event.password);
emit(RegisterAccountSubmitting());
if (event.username.isEmpty ||
event.email.isEmpty ||
event.password.isEmpty) {
emit(RegisterAccountFailure("All fields are required."));
return;
}
print('All fields are written');
try {
// Step 1: Create a new user with Firebase Authentication
final credential =
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: event.email,
password: event.password,
);
print('Added Credentials to FirebaseAuth');
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
emit(RegisterAccountFailure('The password provided is too weak.'));
} else if (e.code == 'email-already-in-use') {
emit(RegisterAccountFailure(
'The account already exists for that email.'));
} else {
emit(RegisterAccountFailure(e.toString()));
}
}
try {
CollectionReference users =
FirebaseFirestore.instance.collection('User');
print("Trying to add");
await users.add({
'username': event.username,
'email': event.email,
'password': event.password
});
print("User Created");
emit(RegisterAccountSuccess());
} catch (error) {
emit(RegisterAccountFailure(error.toString()));
}
},
);
}
}
I tried to debug for hours but no signs of any change at this point. It was working before firebase started showing this message in the authentication tab.
==> Cross origin redirect sign-in is no longer supported in many browsers. Update your app to ensure your users can continue to sign into your app.
there is nothing wrong with your code, this is a firebase auth issue, I was facing the same, all did was update firebase_auth and firebase_core to the latest version, and re-run the app, that solved the issue in my case.