DART post with multipart/form-data


in DART lang, how to specify POST request Content-Type to be


My DART code is:

sendDatas(dynamic data) {
final req = new HttpRequest();
req.onReadyStateChange.listen((Event e) {
  if (req.readyState == HttpRequest.DONE &&
      (req.status == 200 || req.status == 0)) {
    window.alert("upload complete");
req.open("POST", "/upload");


I am doing POST with a file


I think you should use HttpRequest.postFormData(url, data) here. Then you can use the following:

FormData data = new FormData(); // from dart:html

data.append(key, value);

HttpRequest.request('/upload', method: 'POST', sendData: data).then((HttpRequest r) {
  // ...

Regards, Robert

Answered By – Robert

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

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