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/1bfdb3eb32a894a0007f7607708d66b7 to your computer and use it in GitHub Desktop.
Save marcossevilla/1bfdb3eb32a894a0007f7607708d66b7 to your computer and use it in GitHub Desktop.
final client = Dio();
final url = 'https://some-api.dev/';
final directory = await getTemporaryDirectory();
final fileName = '${directory.path}/rant_about_the_world.txt';
final payload = FormData.fromMap({
'user': 'marcossevilla',
'essay': await MultipartFile.fromFile(fileName),
});
await client.post(
'$url/user/new',
data: payload,
onSendProgress: (sent, total) {
final progress = sent / total * 100;
print(progress);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment