Skip to content

Instantly share code, notes, and snippets.

@marcossevilla
Created April 17, 2021 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcossevilla/8c5bc340998f6e453ecb2122bd245da3 to your computer and use it in GitHub Desktop.
Save marcossevilla/8c5bc340998f6e453ecb2122bd245da3 to your computer and use it in GitHub Desktop.
final client = Dio();
final url = 'https://images.unsplash.com/photo-1567026392301-672e510f3369';
final directory = await getTemporaryDirectory();
final fileName = '${directory.path}/downloads';
await client.download(
url,
fileName,
options: Options(headers: {HttpHeaders.acceptEncodingHeader: '*'}),
onReceiveProgress: (received, total) {
if (total != -1) {
final pos = received / total * 100;
print(pos);
}
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment