الرسالة التي ظهر لي ( Something has gone wrong, please try later )
يعني صار catchError
@action
Future<void> getCodeWithPhoneNumber(BuildContext context, String phoneNumber) async {
isLoginLoading = true;
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 60),
verificationCompleted: (AuthCredential auth) async {
await _auth.signInWithCredential(auth).then((AuthResult value) {
if (value != null && value.user != null) {
print('Authentication successful');
onAuthenticationSuccessful(context, value);
} else {
loginScaffoldKey.currentState.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Invalid code/invalid authentication',
style: TextStyle(color: Colors.white),
),
));
}
}).catchError((error) {
loginScaffoldKey.currentState.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Something has gone wrong, please try later',
style: TextStyle(color: Colors.white),
),
));
});
},
verificationFailed: (AuthException authException) {
print('Error message: ' + authException.message);
loginScaffoldKey.currentState.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'The phone number format is incorrect. Please enter your number in E.164 format. [+][country code][number]',
style: TextStyle(color: Colors.white),
),
));
isLoginLoading = false;
},
codeSent: (String verificationId, [int forceResendingToken]) async {
actualCode = verificationId;
isLoginLoading = false;
await Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => const OtpPage()));
},
codeAutoRetrievalTimeout: (String verificationId) {
actualCode = verificationId;
}
);
}
كلمة delete تمت إضافتها بالخطأ، هما فعلا موجودين