Why I can't do a rest api request in Flutter Why I can't do a rest api request in Flutter dart dart

Why I can't do a rest api request in Flutter


The issue is in your body parameters. You can only set a Map<String, String> to the body parameter, in your case it's Map<String, dynamic>.

According to http post documentation:

body sets the body of the request. It can be a String, a List<int> or a Map<String, String>

For fixing it, convert your int type to String:

Map<String,String> data = {   "title":title,   "startDate":startDate,   "startTime":startTime,   "endDate":endDate,   "endTime":endTime,   "description":description,   "city":city,   "address":address,   "entryType":entryType,   "freePlacesCount":freePlacesCount.toString(),};