fix asyncs

This commit is contained in:
Inex Code 2022-04-21 07:12:15 +00:00
parent 449640699f
commit 0e33113516

View file

@ -79,7 +79,9 @@ Future<void> _postOnMastodon(reqJson) async {
final photos =
attachments.where((attachment) => attachment['type'] == 'photo');
final photoUrls = photos.map((photo) async {
List<String> photoUrls = [];
for (final photo in photos) {
final photoUrl = photo['photo']['sizes'].last['url'];
// Generate a random filename.
// Add the extension '.jpg'.
@ -87,8 +89,8 @@ Future<void> _postOnMastodon(reqJson) async {
final photoPath =
'${Directory.systemTemp.path}/$photoFilename';
await dio.download(photoUrl, photoPath);
return photoPath;
});
photoUrls.add(photoPath);
}
// Post the post on Mastodon.
// First we upload all photos with dio.