How can I convert the response of a http.MultipartRequest POST method in a map<String, dynamic> in Flutter?


I am using the following approach:

 var request = http.MultipartRequest('POST', Uri.parse(urlAdicionaItem));
 request.fields["comanda"] = numeroComanda.toString();
 request.fields["produto"] = idProduto.toString();
 request.fields["quantidade"] = quantidade.toString();

 var res = await request.send(); 

But I don’t know how to convert in the response.body to process data like using a regular method.


In your code example res will be a StreamedResponse which can be turned into a String like this:

final responseString = await;

Answered By – dumazy

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.