I have a two-step Login form where the user enters their email first, then is taken to the next page where they enter their password. Prior to taking the user to the password page, I want to check if the email entered by the user is valid and whether it exists in firebase. I have read a few posts about using fetchSignInMethodsForEmail
. However, I'm not quite sure how to implement this.
The idea is if the email does exist the user is taken to the password page, however, if the email does not exist a snackbar pops up with a button taking the user to the register page. How would I go about doing this?
This is what I have so far...
FirebaseAuth auth = FirebaseAuth.instance;
final nextButton = Container(
margin: const EdgeInsets.only(
top: 30.0,
),
child: FloatingActionButton(
onPressed: () async {
try {
List<String> userSignInMethods = await auth.fetchSignInMethodsForEmail(email)(
email: _emailController.text,
);
if (userSignInMethods != null) {
final page = LoginPassword();
Navigator.of(context).push(CustomPageRoute(page));
}
} catch (e) {
print(e);
//TODO: Snackbar
}
},
tooltip: 'Next',
backgroundColor: AppTheme.define().primaryColor,
child: Icon(
AppIcons.next_button,
size: 20.0,
),
),
);
The fetchSignInMethodsForEmail
isn't implemented properly, I'm getting an error.