File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ),
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments