Skip to content

Instantly share code, notes, and snippets.

@xsahil03x
Created March 24, 2019 19:58
Show Gist options
  • Save xsahil03x/807fea30fc180303877fa798734ca2fc to your computer and use it in GitHub Desktop.
Save xsahil03x/807fea30fc180303877fa798734ca2fc to your computer and use it in GitHub Desktop.
Future<void> _onVerifyButtonClick() async {
showProgressBar(context, "Verifying OTP, Please Wait!");
String otp = _otpController.text.trim();
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: _verificationId,
smsCode: otp,
);
await _auth.signInWithCredential(credential).then((user) {
_navigateToHome();
}).catchError((error) {
Navigator.pop(context);
switch (error.code) {
case 'ERROR_INVALID_VERIFICATION_CODE':
showSnackBar(_scaffoldKey, 'Invalid OTP...');
break;
case 'ERROR_SESSION_EXPIRED':
showSnackBar(_scaffoldKey, 'OTP Expired...');
break;
case 'ERROR_INVALID_CREDENTIAL':
showSnackBar(_scaffoldKey, 'Invalid Credentials...');
break;
case 'ERROR_USER_DISABLED':
showSnackBar(_scaffoldKey, 'User Disabled...');
break;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment