【发布时间】:2020-12-03 10:37:29
【问题描述】:
我有一个 IF 条件,其中包含异步代码。我想在继续执行其他代码之前等待条件内的过程完成。如何做到这一点?我的代码如下:
List<String> imageURLs = [];
if (images.length > 0) {
images.forEach((element) async {
String imageURL = await savePostImage(element);
imageURLs.add(imageURL);
});
} //This should complete
data.addAll({'images': imageURLs}); /For this to be executed
【问题讨论】:
标签: flutter asynchronous dart async-await