Skip to content

Commit 2db2d50

Browse files
committed
minor fixes
1 parent 7ffe9ec commit 2db2d50

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

example/lib/screens/verify_phone_number_screen.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class _VerifyPhoneNumberScreenState extends State<VerifyPhoneNumberScreen>
9595
);
9696
},
9797
onLoginFailed: (authException) {
98+
if (authException.code == 'invalid-verification-code') {
99+
// invalid otp entered
100+
return showSnackBar('The entered OTP is invalid!');
101+
}
102+
98103
showSnackBar('Something went wrong!');
99104
log(VerifyPhoneNumberScreen.id, error: authException.message);
100105
// handle error further if needed
@@ -186,11 +191,14 @@ class _VerifyPhoneNumberScreenState extends State<VerifyPhoneNumberScreen>
186191
if (hasFocus) await _scrollToBottomOnKeyboardOpen();
187192
},
188193
onSubmit: (enteredOtp) async {
189-
final isValidOtp =
194+
final verified =
190195
await controller.verifyOtp(enteredOtp);
191-
// Incorrect OTP
192-
if (!isValidOtp) {
193-
showSnackBar('The entered OTP is invalid!');
196+
if (verified) {
197+
// number verify success
198+
// will call onLoginSuccess handler
199+
} else {
200+
// phone verification failed
201+
// will call onLoginFailed or onError callbacks with the error
194202
}
195203
},
196204
),

lib/src/auth_handler.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class FirebasePhoneAuthHandler extends StatefulWidget {
6868
///
6969
/// Make sure a user is signed in already, else an error is thrown.
7070
///
71+
/// NOTE: Does not work on web platforms.
72+
///
7173
/// Defaults to false
7274
///
7375
/// {@endtemplate}

0 commit comments

Comments
 (0)