Open kawa-yo opened 1 year ago
@kawa-yo Since all the file operations are asynchronous you must use either below syntax:
await file1.writeAsString("$i times\n", mode: FileMode.append);
or
file2.writeAsStringSync("$i times\n", mode: FileMode.append);
Your async.txt will not get the expected result until you use the await keyword before the method call.
I was trying to log to a file using logging. Here's the code.
Resulting file was just one line, a message
logger
somewhere listened.When I replaced
writeAsString
withwriteAsStringSync
, things went well and all messages were logged to the file.Is this an expected behavior?
Minimized code
async.txt
sync.txt