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:
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.
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);
}