I think changing your firebase database security rules to the public is not advisable.
But I could understand your situation. I could give you an idea.
This is how I implement it, without changing the security rules.
WHEN YOU WANT TO CHECK AFTER CLICKING THE BUTTON:
//SIGN UP
try {
UserCredential userCredential = await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: "USER ENTERED PASSWORD",
password: "SuperSecretPassword!"
);
} on FirebaseAuthException catch (e) {
if (e.code == 'email-already-in-use') {
print('The account already exists for that email.');
// Tell User That It already exists!
}
} catch (e) {
print(e);
}
// Or SIGN IN
try {
UserCredential userCredential = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: "[email protected]",
password: "SuperSecretPassword!"
);
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
print('No user found for that email.');
} else if (e.code == 'wrong-password') {
print('Wrong password provided for that user.');
}
}
WHEN YOU WANT TO CHECK WHILE TYPING IN EMAIL TEXTFIELD:
UserCredential userCredential = await FirebaseAuth.instance.signInAnonymously();
You could sign in anonymously and read the database! After reading and filtering out log out the user.
Or else if you haven't convinced yet, then here you go,
Refer: https://firebase.google.com/docs/rules/basics#content-owner_only_access
Make read to public and write to auth users.
Hope that suits your case!