Flutter send empty file to server

Hi i’m trying to upload a file to a server via a flutter app but the file is always empty. it was working fine and after that it stopped working.

here is my code :

static uploadImageToServer(String image) async {
File imageFile = new File(image);

Map<String, String> headers = {
  'Content-Type': 'multipart/form-data',
  'Accept-Charset': 'UTF-8'
};

var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead()));
var length = await imageFile.length();
print(imageFile.path);

var uri = Uri.parse("http://planning.test/test_image");

var request = new http.MultipartRequest("POST", uri);

var multipartFile = new http.MultipartFile('File', stream, length,
    filename: "test_image_failure.jpg");

request.headers.addAll(headers);
request.fields['Destination'] = '/';

print("**********");
print(multipartFile.filename);
print(uri);
print(multipartFile.length);
print("**********");

request.files.add(multipartFile);

print(request.contentLength);

var response = await request.send();

print(response.statusCode);

response.stream.transform(utf8.decoder).listen((value) {
  print(value);
});

}

and with dio package

_dioUpload(String imageFile)async {
var dio = Dio();
var formData = FormData();
formData.files.add(MapEntry(
  "File",
  await MultipartFile.fromFile(imageFile, filename: "xx.png"),
));

print(formData.files.first.value.length);
var response = await dio.post(
    "http://planning.test/test_image",
    data: formData,
  onSendProgress: (received, total) {
    if (total != -1) {
      print((received / total * 100).toStringAsFixed(0) + "%");
    }
  },
);
print(response);

}

i don’t understand what is happening everything look fine and the file exist.

thx

Even I’m facing the same issue. please do inform when you get the solution.