Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter internal error while using signInWithEmailAndPassword

I’m trying to create a sign-in form using flutter and firebase. I’m facing the following error while using the signInWithEmailAndPassword function:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_auth/internal-error] An internal error has occurred, print and inspect the error details for more information.

Code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

body: Column(children: [
          TextField(
            controller: _email,
            keyboardType: TextInputType.emailAddress,
            enableSuggestions: false,
            autocorrect: false,
            decoration: const InputDecoration(
              border: OutlineInputBorder(), hintText: "Email"),
          ),
          TextField(
            controller: _password,
            obscureText: true,
            enableSuggestions: false,
            autocorrect: false,
            decoration: const InputDecoration(
              border: OutlineInputBorder(), hintText: "Password"),
          ),
          TextButton(
            onPressed: () async {
              final email = _email.text;
              final password = _password.text;
              await Firebase.initializeApp(
                options: DefaultFirebaseOptions.currentPlatform,
              );
              final userCredential = 
                await FirebaseAuth.instance.createUserWithEmailAndPassword(
                  email: email, password: password
                );
              print(userCredential);
            },
            child: const Text("Register"),
          )
        ])

I tried unrestricting my API keys from the Google Cloud Console, but that didn’t work. I’m using an IOS simulator. How can I solve this? Thanks in advance.

>Solution :

Try to catch the error you get and print it! Then you probably get some more information. Maybe your input is incorrect.

Try this:

try {
  await FirebaseAuth.instance.signInWithEmailAndPassword(
    email: "barry.allen@example.com",
    password: "SuperSecretPassword!"
  );
} on FirebaseAuthException catch  (e) {
  print('Failed with error code: ${e.code}');
  print(e.message);
}

https://firebase.google.com/docs/auth/flutter/errors

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading