'Error calling provider on button click (FORM SAVED)

I am posting a map on button click using provider, which calls Chopper service to post a map data to the server. It gives an error to the server which is something like this.

I/flutter ( 4801): Observatory listening on ************************************
E/flutter ( 4801): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Converting object to an encodable object failed: Instance of 'DateTime'
E/flutter ( 4801): #0      _JsonStringifier.writeObject (dart:convert/json.dart:688:7)
E/flutter ( 4801): #1      _JsonStringifier.writeMap (dart:convert/json.dart:769:7)
E/flutter ( 4801): #2      _JsonStringifier.writeJsonValue (dart:convert/json.dart:724:21)
E/flutter ( 4801): #3      _JsonStringifier.writeObject (dart:convert/json.dart:679:9)
E/flutter ( 4801): #4      _JsonStringStringifier.printOn (dart:convert/json.dart:877:17)
E/flutter ( 4801): #5      _JsonStringStringifier.stringify (dart:convert/json.dart:862:5)
E/flutter ( 4801): #6      JsonEncoder.convert (dart:convert/json.dart:262:30)
E/flutter ( 4801): #7      JsonCodec.encode (dart:convert/json.dart:172:45)
E/flutter ( 4801): #8      JsonConverter.encodeJson
E/flutter ( 4801): #9      JsonConverter.convertRequest
E/flutter ( 4801): #10     ChopperClient._encodeRequest
E/flutter ( 4801): #11     ChopperClient._handleRequestConverter
E/flutter ( 4801): #12     ChopperClient.send
E/flutter ( 4801): #13     _$PersonalPostingService.postPersonal
E/flutter ( 4801): #14     _FormState.build.<anonymous closure>.<anonymous closure>
E/flutter ( 4801): #15     _FormState.build.<anonymous closure>.<anonymous closure>
E/flutter ( 4801): #33     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
E/flutter ( 4801): #34     _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
E/flutter ( 4801):
Exited (1)

This is where I am calling the function the body is a MAP of string, dynamic

child: RaisedButton(
                                  onPressed: () async {
                                    final form = _formKey.currentState;

                                    if (form!.validate()) {
                                      form.save();
                                      showNotification();
                                       await Provider.of<PersonalPostingService>(
                                              context,
                                              listen: false)
                                          .postPersonal(data);
                                    }
                                  },
                                  child: Text('Save'))),

The GET requests are working fine and are easily being displayed in a listview but the POST function is not working, just for the reference below is the chopper service for POST

@Post(path: 'http://157.......:8040/personal')
  Future<Response> postPersonal(
    @Body() Map<String, dynamic> body,
  );


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source