createAccount method

Future<void> createAccount(
  1. String email,
  2. String password,
  3. dynamic successfulFunction,
  4. dynamic weakPassword,
  5. dynamic userFound,
  6. dynamic exceptionFunction,
)

create account....

Implementation

Future<void> createAccount(
    String email,
    String password,
    var successfulFunction,
    var weakPassword,
    var userFound,
    var exceptionFunction) async {
  try {
    Constants.firebaseAuth
        .createUserWithEmailAndPassword(email: email, password: password)
        .then((value) => successfulFunction())
        .onError((error, stackTrace) => exceptionFunction())
        .timeout(const Duration(seconds: 30));
  } on FirebaseAuthException catch (e) {
    print("Firebase exception");
    print(e.toString());
    if (e.code == 'weak-password') {
      print('The password provided is too weak.');
      weakPassword();
    } else if (e.code == 'email-already-in-use') {
      print('The account already exists for that email.');
      userFound();
    }
  }
}