append method
Adds text to the end of the file at path, after separator when
the file already has content. Creates the file if needed.
Implementation
Future<void> append(String path, String text, {String separator = '\n'}) =>
_run(path, () async {
_guardWrite('append');
final String target = _resolve(path);
final DiskEntry? entry = await driver.stat(target);
final bool hasContent =
entry != null && entry.isFile && (entry.size ?? 0) > 0;
await driver.write(
target,
utf8.encode(hasContent ? '$separator$text' : text),
append: true,
);
_written(target);
});