Skip to content

Instantly share code, notes, and snippets.

@yaizudamashii
Created July 19, 2021 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaizudamashii/90224210ae17e2a794eb7432516058b8 to your computer and use it in GitHub Desktop.
Save yaizudamashii/90224210ae17e2a794eb7432516058b8 to your computer and use it in GitHub Desktop.
// Form submit関数だけ抜粋
Future<bool> submit() async {
try {
updateWith(submitted: true);
if (!canSubmit) {
return false;
}
updateWith(isLoading: true);
switch (formType) {
case EmailPasswordSignInFormType.signIn:
await firebaseAuth.signInWithCredential(
EmailAuthProvider.credential(email: email, password: password)
);
break;
case EmailPasswordSignInFormType.register:
UserCredential userCredential = await firebaseAuth.createUserWithEmailAndPassword(
email: email, password: password
);
await FirestoreService.createUser(userCredential);
break;
case EmailPasswordSignInFormType.forgotPassword:
await firebaseAuth.sendPasswordResetEmail(email: email);
updateWith(isLoading: false);
break;
}
return true;
} catch (e) {
updateWith(isLoading: false);
rethrow;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment