I am trying to add Firebase Phone Authentication in my app but getting error every time when I want to send tel number to firebase. It states that - unrecognized selector sent to instance 0x20d326df8. I am using real IPhone not simulator. Here is the some part of my code:
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
height: 60,
child: ElevatedButton(
style: phoneNumber.toString().length > 7
? mainButtonStyle
: ElevatedButton.styleFrom(
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
primary: Colors.orange.shade200),
onPressed: () async {
FocusManager.instance.primaryFocus!.unfocus();
if (phoneController.text.isNotEmpty &&
phoneController.text.length > 7) {
setState(() {
showLoading = true;
});
await _auth.verifyPhoneNumber(
phoneNumber: codeOfGermany + phoneController.text,
verificationCompleted: (phoneAuthCredential) async {
setState(() {
showLoading = false;
});
},
verificationFailed: (verificationFailed) async {
setState(() {
showLoading = false;
});
print(codeOfGermany + phoneController.text);
showSnackBar(
context,
'Etwas ist schief gelaufen. Bitte überprüfen Sie Ihre Nummer und Verbindung und versuchen Sie es erneut',
iconDataForSnackBarInfo,
3);
Text(verificationFailed.toString())));
},
codeSent: (verificationId, resendingToken) async {
setState(() {
showLoading = false;
currentState =
MobileVerificationState.SHOW_OTP_FORM_STATE;
this.verificationId = verificationId;
});
},
codeAutoRetrievalTimeout: (verificationId) async {},
);
} else {
errorMessage = 'Phone number not included';
}
},
child: Text(
"Send",
style: buttonTextStyleBlack,
),
),
),
),
),
What I have tried:
Additionally when I am using in TextFormField - keyboardType: TextInputType.number it gives an error such as: Can't find keyplane that supports type 4 for keyboard iPhone-PortraitTruffle-NumberPad; using 27071_PortraitTruffle_iPhone-Simple-Pad_Default. I removed it and only this error gone. But In thix TextFormField user should add tel number and I need show them only number.
Your help highly appreciated