date_time_picker icon indicating copy to clipboard operation
date_time_picker copied to clipboard

Validator Doest Work.

Open threegeeks opened this issue 4 years ago • 3 comments

I tried validator: (val) { DateTime fDate = DateTime.parse(val); print(fDate.weekday); if(fDate.weekday == 1){ return 'false'; } return null; }

But i didn't got the print value.

threegeeks avatar Feb 26 '21 07:02 threegeeks

I tried the same code, and it works fine. But I don't know when you want to get this, because the validator will be called after form save. So, the widget need to be a child of form widget.

hslbetto avatar Mar 03 '21 01:03 hslbetto

Having the same problem here.

Validator is working for normal TextFormField:

validator: (val) { if (val == null || val.isEmpty) return 'Please enter something'; },

However, when putting the same Validator into the DateTimePicker Widget _formkey.currentState!.validate() return always true which is not the case. What am I doing wrong here?

florianh01 avatar Mar 22 '21 22:03 florianh01

Having the same problem here.

Validator is working for normal TextFormField:

validator: (val) { if (val == null || val.isEmpty) return 'Please enter something'; },

However, when putting the same Validator into the DateTimePicker Widget _formkey.currentState!.validate() return always true which is not the case. What am I doing wrong here?

Ok, I just found the issue. You have to check for val == 'null' (null as a String). Then it works fine.

florianh01 avatar Mar 22 '21 22:03 florianh01