I am trying to send an DateTime instance per Json. I know how to decode DateTime from a Json file. But how can I encode it correctly?
DateTime birthdate; Map<String, dynamic> toJson() => { 'birthDate': birthdate, };
Does not work
I am trying to send an DateTime instance per Json. I know how to decode DateTime from a Json file. But how can I encode it correctly?
DateTime birthdate; Map<String, dynamic> toJson() => { 'birthDate': birthdate, };
Does not work
Here is a sample:
Map<String, dynamic> toJson() {
DateTime myBirthday = DateTime.now();
Map<String, dynamic> jsonObject = {
'birthday': myBirthday,
};
return jsonObject;
}