Dart: Get POST parameters on server side


I send some data from client side using POST request

var value = new Map<String, String>();
value["param1"] = 'value1';
value["param2"] = 'value2';
value["param3"] = 'value3';

HttpRequest.postFormData('http://localhost:8080/', value);

and try to get this data on the server side:

HttpServer.bind(InternetAddress.ANY_IP_V6, 8080).then((server) {
    server.listen((HttpRequest request) {
        //TODO: process POST request

But how can I get POST values from the request as Map< string, string>?

upd 1

But as I see result of

var jsonString = await request.transform(UTF8.decoder).join();

depends on type of post message. If I change it result will be


Content-Disposition: form-data; name="param1"

value 1
Content-Disposition: form-data; name="param2"

value 2
Content-Disposition: form-data; name="param3"

value 3


param1=value 1
param2=value 2
param3=value 3



As I have already asked how can I convert it to Map< string, string>?


Here is a complete tutorial https://www.dartlang.org/docs/tutorials/httpserver/#handling-post

String jsonString = await request.transform(UTF8.decoder).join();


Map result = await request.transform(UTF8.decoder).join().then(JSON.decode);

Answered By – Günter Zöchbauer

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *