This is my code but i get this error :
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Content size exceeds specified contentLength. 17282 bytes written while expected 398.
uploadFile(File imageFile,String id,LoginResponseModel responseModel) async {
var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead()));
var length = await imageFile.length();
var uri = Uri.parse(BASE_URL+"/jobs/"+id+"/signatures/");
Map<String, String> headers = { "Accept": "application/json",
"content-type": "application/json",
"Authorization": "Bearer " + responseModel.access};
var request = new http.MultipartRequest("POST", uri);
request.headers.addAll(headers);
request.fields['name'] = 'test';
var multipartFile = new http.MultipartFile('signature', stream, length,
filename: basename(imageFile.path));
request.files.add(multipartFile);
var response = await request.send();
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
});
}