write method

Future<void> write(
  1. String line, {
  2. String? newline,
})

Truncates the file to zero bytes and then writes the given text to the file. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator.

Implementation

Future<void> write(String line, {String? newline}) async {
  final finalline = line + (newline ?? Platform().eol);
  final r = await _raf;

  r
    ..truncateSync(0)
    ..setPositionSync(0)
    ..writeStringSync(finalline)
    ..flushSync();
}