1 Future<ApiResponse<bool>> uploadfile(File file) async {
2
3 var stream = new http.ByteStream(DelegatingStream(file.openRead()));
4 var length = await file.length();
5 var uri = Uri.parse("Enter your URL");
6 var request = new http.MultipartRequest("POST", uri);
7 var multipartFile = new http.MultipartFile('data', stream, length, filename: basename(file.path));
8 request.files.add(multipartFile);
9 await request.send().then((response) {
10 response.stream.transform(utf8.decoder).listen((value) {
11 file.delete();
12 print(value);
13 });
14
15 }).catchError((e) {
16 print(e);
17 });
18 }
19