calculatePadding static method

int calculatePadding(
  1. int offset,
  2. int alignment
)

Calculate padding needed to align to the given boundary

  • offset: The current offset
  • alignment: The alignment boundary Returns the padding needed to align to the boundary

Implementation

static int calculatePadding(int offset, int alignment) {
  if (alignment <= 1) return 0;
  final remainder = offset % alignment;
  return remainder == 0 ? 0 : alignment - remainder;
}