Skip to content

Instantly share code, notes, and snippets.

@nkenna
Created September 18, 2021 09:00
Show Gist options
  • Save nkenna/9d7ed19260cf5a374a6a91ac7aba1e99 to your computer and use it in GitHub Desktop.
Save nkenna/9d7ed19260cf5a374a6a91ac7aba1e99 to your computer and use it in GitHub Desktop.
Future<void> downloadFile() async {
downloading = true;
Dio dio = Dio();
try {
var dir = await getApplicationDocumentsDirectory();
await dio.download(
"https://piccity/223433.png",
"${dir.path}/downloaded.png",
onReceiveProgress: (rec, total) {
print("Rec: $rec , Total: $total");
});
} catch (e) {
print(e);
}
print("Download completed");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment