validateAlignment static method

void validateAlignment(
  1. int offset,
  2. int alignment
)

Validates the alignment of the given offset.

  • offset: The offset to validate.
  • alignment: The required alignment.

Implementation

static void validateAlignment(int offset, int alignment) {
  if (offset % alignment != 0) {
    throw StateError(
        'Misaligned memory access: offset $offset is not aligned to $alignment bytes');
  }
}