toInt method Null safety

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.


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


int toInt();