Hi @jaumard
While using your package, everything is working for getting mobile device phone number, but when leaving the field blank it is not calling the validator function.
I had debugged it and attached a breakpoint on the validator function, but the debugger is not going to that validator function breakpoint.
However, the flutter provided TextFormField is returning me the value from validator but your package is not.
Hi @jaumard While using your package, everything is working for getting mobile device phone number, but when leaving the field blank it is not calling the validator function. I had debugged it and attached a breakpoint on the validator function, but the debugger is not going to that validator function breakpoint. However, the flutter provided TextFormField is returning me the value from validator but your package is not.
Here is my code: `Form( key: _formKey, autovalidateMode: _autoValidateMode, child: Column(children:[
TextFormField(
textInputAction: TextInputAction.next,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
keyboardType: TextInputType.number,
validator: (value) =>
Validator.generalValidation(value!, "Phone Number"),
textAlign: TextAlign.left,
decoration: InputDecoration(
prefixIcon: Icon(Icons.phone),
errorText: null,
labelText: "Phone Number",
hintText: "(555) 555-5555",
labelStyle: TextStyle(color: Colors.black),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(),
),
),
onSaved: (value) {
_userServiceViewModel.phoneNumber = value;
},
),
PhoneFormFieldHint(
validator: (value) =>
Validator.generalValidation(value!, "Phone Number"),
child: TextField(
focusNode: focusNode,
controller: phoneController,
textInputAction: TextInputAction.next,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
keyboardType: TextInputType.number,
textAlign: TextAlign.left,
decoration: InputDecoration(
prefixIcon: Icon(Icons.phone),
errorText: null,
labelText: "Phone Number",
hintText: "(555) 555-5555",
labelStyle: TextStyle(color: Colors.black),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
borderSide: BorderSide(),
),
),
),
),
Row(
children: [
Expanded(
child: TextButton(
onPressed: () async {
if (_validateInputs() == false) return;
Here is my _validateInputs function:
bool _validateInputs() { final FormState form = _formKey.currentState!; if (!form.validate()) { setState(() { _autoValidateMode = AutovalidateMode.always; // Start validating on every change. }); return false; } else { form.save(); // Encrypt and send send payment details to payment gateway // showSnackBar(context, 'Payment card is valid'); return true; } }
Kindly have a look into this
Thanks