nextBigIntBetween method

BigInt nextBigIntBetween(
  1. BigInt min,
  2. BigInt max
)

generates a random BigInt between min inclusive and max exclusive

Implementation

BigInt nextBigIntBetween(BigInt min, BigInt max) {
  assert(min < max, '$min should be less than $max.\nNot greater nor equal');
  final sorted = [min, max].sorted();
  final a = sorted.first;
  final b = sorted.last;
  final diff = b - a;
  final r = nextBigInt(diff);

  return a + r;
}