add await for file download

This commit is contained in:
Inex Code 2022-04-21 07:09:41 +00:00
parent 2d72315584
commit 449640699f
1 changed files with 2 additions and 2 deletions

View File

@ -79,14 +79,14 @@ Future<void> _postOnMastodon(reqJson) async {
final photos =
attachments.where((attachment) => attachment['type'] == 'photo');
final photoUrls = photos.map((photo) {
final photoUrls = photos.map((photo) async {
final photoUrl = photo['photo']['sizes'].last['url'];
// Generate a random filename.
// Add the extension '.jpg'.
final photoFilename = '${DateTime.now().millisecondsSinceEpoch}-${photoUrl.split('/').last.split('?').first.substring(0, 10)}.jpg';
final photoPath =
'${Directory.systemTemp.path}/$photoFilename';
dio.download(photoUrl, photoPath);
await dio.download(photoUrl, photoPath);
return photoPath;
});