I have a program like the following:
main() async {
ooClass = new OoClass(1);
int val = await function1();
print(val);
ooClass = new OoClass(2);
va
Yes, await
is permitted inside a for
loop in Dart, and it will work as expected.
for (var o in objects) {
await doSomething(o);
}
And there is even await for
for Streams, if that's what you're looking for:
await for (var event in eventStream) {
print("Event received: $event");
}
Your example works correctly in DartPad. It's too complex & abstract to debug but, at least superficially, it should work. You say that the snippet doesn't work in your "real environment", though. Maybe we could help if you explained what you mean by that?
Additional tip: take full advantage of static analysis, especially the await_only_futures and unawaited_futures linter rules. This can help you catch many bugs.