Here is my code:
Map<String, dynamic>? myMap = { 'conversationId': iD, 'type': 'text', 'data': _controller.text.toString(), 'msgLength':_controller.text.length, 'senderId': Provider.of( context,listen: false).id, 'createdOn': 190823, 'messageState': 'delivered', 'isDeleted': 0, 'id': 3048, };
String encoded = json.encode(myMap);
// Make the POST request and wait for the response
final response = await postRequest(url: conversationUrl,
body: encoded,
headers:{'Content-Type': 'application/json'},);
BUT I AM SHOWN a RED LINE UNDER encoded in the body parameter, with the error: The argument type 'String' can't be assigned to the parameter type 'Map<String, dynamic>?'
I have tried (Dart HTTP POST with Map<String, dynamic> as body) changes, now what?
Alas! the answer to my problem is to use dart.io library's httpRequest method that allows custom headers in a http request !