isMultipleOf method

bool isMultipleOf(
  1. BigInt other
)

Returns true if this BigInt is a multiple of other

Example:

BigInt.from(10).isMultipleOf(BigInt.from(5)); // true
BigInt.from(11).isMultipleOf(BigInt.from(5)); // false
BigInt.zero.isMultipleOf(BigInt.from(5));     // true (0 is a multiple of any number)

Throws:

  • ArgumentError: If other is zero

Implementation

bool isMultipleOf(BigInt other) {
  if (other == BigInt.zero) {
    throw ArgumentError('Cannot check if a number is a multiple of zero');
  }
  return this % other == BigInt.zero;
}