alignTo method

BigByteConverter alignTo(
  1. int alignment
)

Aligns the byte count up to the specified alignment.

Example: alignTo(4096) for page alignment.

Implementation

BigByteConverter alignTo(int alignment) {
  if (alignment <= 0) throw ArgumentError('Alignment must be positive');
  final bytes = _converter.bytes;
  final a = BigInt.from(alignment);
  final aligned = ((bytes + a - BigInt.one) ~/ a) * a;
  return BigByteConverter(aligned);
}