I am using the formBuilder package to design a form for user to fill in, but I got 2 problems:
I set initialValues for form fields, but when I submit, formValues contains nothing, but if I change the value a little bit on the UI, formValues shows 开发者_如何学编程correct info.
if there is a DateTimePicker in the form, jsonEncode returns error: Converting object to an encodable object failed: Instance of 'DateTime'
Please help.
formValues['expirydate'] = formValues['expirydate'].toIso8601String();
and this seem not work either
You can't encode a DateTime
object with the jsonEncode()
method. Instead, you must convert it to a string or a number before encoding. For example:
String dateString = formValues['expirydate'].toIso8601String();
String encodedString = jsonEncode(dateString);
精彩评论