abort method

  1. @override
Future<void> abort(
  1. Object reason
)
override

Truncates the file to zero length: it holds only the output of the operation that ended cancelled or failed. Call it before close; on a closed sink it does nothing.

Implementation

@override
Future<void> abort(Object reason) async {
  if (_closed) return;
  try {
    await _writing;
  } catch (_) {
    // A failed write may be what ended the operation; the file is
    // truncated all the same.
  }
  await _raf.truncate(0);
  await _raf.setPosition(0);
}