getInteger method

BigInt getInteger()

Converts the value stored in the CborObject to a BigInt.

Throws a MessageException if the value is not of type int or BigInt.

Implementation

BigInt getInteger() {
  if (value is! int && value is! BigInt) {
    throw MessageException("Failed to cast value to integer.", details: {
      "Value": value,
      "Type": value.runtimeType,
    });
  }
  if (value is int) return BigInt.from(value);
  return value;
}