This is My Custom validation textfield
CmnTextField(
labelText: "Location",
controller: LocationController,
readOnly: true,
autoValidateMode: controller.unit
? AutovalidateMode.always
: AutovalidateMode.disabled,
onTap: () async {
final result = await Navigator.of(context).push(MaterialPageRoute(
builder: (_) => SelectLocation(whichLocation: 'From Location')));
if (result != null && result is Locations) {
_assignFromLocation(result);
}
},
validator: _validateInput,
enabled: isEdit
? false
: controller.isMove ||
controller.isCustomMove ||
controller.unit,
),
This is my validation Function:
String? _validateInput(String? value) {
if (controller.unit) {
if (value == null || value.isEmpty) {
return 'required';
}
}
return null;
}
When controller.unit this is condition is true make disable textfield and remove validation and when this condition is false at time i need on autovalidation mode so how i can achieve this?
if anyone have any idea then tell me
lang-dart
controller.unitis nullvalidator: controller.unit ? null : _validateInput,