I try to modify a string using data in each node I retrieve from Firebase database, and then to write a file with the modifed string (called \"content\").
He
If you use for(... in )
instead of forEach
you can use async
/await
Future someMethod() async {
...
for(final jsonString in response.value) {
...
// cacheManager.getFile returns a Future
cacheManager.getFile(signedurl).then((file){
// Modify content
content=content.replaceAll('test',file.path);
});
});
}
With forEach
the calls fire away for each jsonString
immediately and inside it await
works, but forEach
has return type void
and that can't be awaited, only a Future
can.