Created
July 19, 2021 19:06
-
-
Save yaizudamashii/90224210ae17e2a794eb7432516058b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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