covariant method

  1. @override
bool covariant(
  1. dynamic x
)
override

Assert that JavaScript's x is the proper type represented by this Type.

Implementation

@override
bool covariant(x) {
  final min = BigInt.from(2).pow(_bits - 1) * BigInt.from(-1);
  final max = BigInt.from(2).pow(_bits - 1) - BigInt.one;
  if (x is BigInt) {
    return x >= min && x <= max;
  } else if (x is int) {
    final v = BigInt.from(x);
    return v >= min && v <= max;
  } else {
    return false;
  }
}