flutter save json to file
Future<ApiResponse<bool>> uploadfile(File file) async {
var stream = new http.ByteStream(DelegatingStream(file.openRead()));
var length = await file.length();
var uri = Uri.parse("Enter your URL");
var request = new http.MultipartRequest("POST", uri);
var multipartFile = new http.MultipartFile('data', stream, length, filename: basename(file.path));
request.files.add(multipartFile);
await request.send().then((response) {
response.stream.transform(utf8.decoder).listen((value) {
file.delete();
print(value);
});
}).catchError((e) {
print(e);
});
}