toInt method

int? toInt()

Returns this BigInt as an int.

If the number does not fit, clamps to the max (or min) integer.

Warning: the clamping behaves differently between the web and native platforms due to the differences in integer precision.

Example:

var bigNumber = BigInt.parse('100000000000000000000000');
print(bigNumber.isValidInt); // false
print(bigNumber.toInt()); // 9223372036854775807

Implementation

int? toInt() => value?.toInt();