skip to Main Content

Some Error Occured type ‘List<Object?>’ is not a subtype of type ‘PigeonUserDetails?’ in type cast

Upgrade all the dependency related to firebase login or firebase cloud.

Before this error arose everything was working fine in the project.

Here is the method that I used for firebase login through email and password.

  Future<User?> signInWithEmailAndPasswrod(String email, String password) async{

    try{
      UserCredential credential = await _auth.signInWithEmailAndPassword(email: email, password: password);
      return credential.user;
    }
    catch(err){
      debugPrint("Some Error Occured $err");
    }
    return null;
  }

2

Answers


  1. I think typeCast problem is where you’re using this function.

    userLogin = signInWithEmailAndPasswrod("yourEmailAddress", "yourPassword")

    Rather than returning that credential I would suggest to use credentials as below.

     void login() async {
        try {
          final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(
            email: loginEmailController.text.trim(),
            password: loginPasswordController.text.trim(),
          );
          if (credential.user != null) {
           
         // Set value here and Navigate to Home Screen.
    
          }
        } on FirebaseAuthException catch (e) {
          if (e.code == 'user-not-found') {
            showSnackBar('No user found for that email.');
          } else if (e.code == 'wrong-password') {
            showSnackBar('Wrong password provided for that user.');
          } else if (e.code == 'invalid-credential') {
            showSnackBar('Invalid credential.');
          }
        }
      }
    
    Login or Signup to reply.
  2. I faced a similar issue where some of my Firebase packages wouldn’t update past a certain version after running flutter pub upgrade. Upon investigation, I realized that the issue was caused by the cached_network_image package.

    Here’s how I resolved the problem:

    1. I removed the cached_network_image package from my project.
    2. Then, I ran flutter clean to clear the build cache.
    3. Next, I executed flutter pub get to fetch dependencies.
    4. Finally, I ran flutter pub upgrade to ensure all packages were up-to-date.

    P.S. Uninstall the app on the device as well; ensure a completely clean build.

    After these steps, everything returned to normal, and the Firebase packages upgraded successfully.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search