I want to add header with access_token for flutter upload image I want to add header with access_token for flutter upload image dart dart

I want to add header with access_token for flutter upload image


Can you try to add headers like below

Map<String, String> headers = { "Accesstoken": "access_token"};final multipartRequest = new http.MultipartRequest('POST', Uri.parse(apiUrl))multipartRequest.headers.addAll(headers);multipartRequest.files.add(..)


  var request = http.MultipartRequest(    "POST",    Uri.parse(      "${Urls().url}/support/tenant/register",    ),  );  //add text fields    request.headers["authorization"]=userToken;  request.fields["type"] = type;  request.fields["note"] = note;  for (var item in path) {    var ext = item.split('.').last;    var pic = await http.MultipartFile.fromPath("images", item, contentType: MediaType('image', ext));    request.files.add(pic);  }  //add multipart to request  var response = await request.send();  var responseData = await response.stream.toBytes();  var responseString = String.fromCharCodes(responseData);  var d = jsonDecode(responseString);