0

I'm trying to upload a snackBar in case of error but nothing appears on the screen, neither error nor the snackBar

onFail doesn't work !

class UserManager {
  final FirebaseAuth auth = FirebaseAuth.instance;

  Future<void> signIn({required UserPerson userPerson, required Function onFail, required Function onSuccess}) async {
    
    try {
      
      final UserCredential credential = await auth.signInWithEmailAndPassword(email: userPerson.email, password: userPerson.password);

      onSuccess();
    }
    on PlatformException catch (e) {
     
    onFail(getErrorString(e.code));
    }
  }
}

enter image description here

1 Answers1

1

Directly add catch. Right now it is triggered only on platform exceptions..

try {
      
      final UserCredential credential = await auth.signInWithEmailAndPassword(email: userPerson.email, password: userPerson.password);

      onSuccess();
    }
    catch (e) {   
    onFail(getErrorString(e.code));
    }
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30