truncate method

  1. @override
Future<void> truncate(
  1. int newLength
)
override

Resizes the container to newLength bytes (shrinking discards tail bytes).

Implementation

@override
Future<void> truncate(int newLength) async {
  RangeError.checkNotNegative(newLength, 'newLength');
  if (readOnly) {
    throw const WalPackReadOnlyException();
  }
  final raf = _requireOpen();
  try {
    _knownPos = -1;
    if (ioMode != .async) {
      raf.truncateSync(newLength);
    } else {
      await raf.truncate(newLength);
    }
  } finally {
    _releaseIfTransient();
  }
}