alignTo method

ByteConverter alignTo(
  1. int alignment
)

Aligns the byte count up to the specified alignment.

Example: alignTo(4096) for page alignment.

Implementation

ByteConverter alignTo(int alignment) {
  if (alignment <= 0) throw ArgumentError('Alignment must be positive');
  final bytes = _converter.bytes.toInt();
  final aligned = ((bytes + alignment - 1) ~/ alignment) * alignment;
  return ByteConverter(aligned.toDouble());
}