parse static method
Parses a dynamic value number into a BigInt.
Throws:
- ArgumentException if the input value cannot be parsed into a BigInt.
Implementation
static BigInt parse(dynamic number, {bool allowHex = true}) {
if (number is BigInt) return number;
if (number is int) return BigInt.from(number);
if (number is String) {
BigInt? parse = BigInt.tryParse(number);
if (parse == null && allowHex) {
parse = BigInt.tryParse(StringUtils.strip0x(number), radix: 16);
}
if (parse != null) return parse;
}
throw ArgumentException.invalidOperationArguments(
"parse",
name: "number",
reason: "Failed to parse value as BigInt",
);
}