Flutter - .json file content changes after downloading and storing it in application storage using Dio

Viewed 33

I am using Dio in Flutter to download the json file as below :

 Future<void> downloadFile() async {
// requests permission for downloading the file
bool hasPermission = await _requestWritePermission();
if (!hasPermission) return;

Dio dio = Dio();
try {
  var dir = await getApplicationDocumentsDirectory();
  await dio.download(uri, "${dir.path}/eng_json.json",
      onReceiveProgress: (rec, total) {
    print("Path >>> " + "${dir.path}/eng_json.json");
    setState(() {
      downlodingPercentage=((rec*100)/total).toInt();
      downloading = true;
    });
  });
} catch (e) {
  print("Error >> " + e.toString());
}
setState(() {
  downloading = false;
  print("Download Completes");
    });
  }

Used above code. It works fine and I can store the file in application storage. But The issue is when I have checked content inside downloaded .json file, It changes as below :

enter image description here

What might be the issue? Thanks in advance.

0 Answers
Related