The `toInt()` method of BigInt class returns this BigInt as an integer.
The syntax of BigInt.toInt() method is:
int toInt()
This toInt() method of BigInt returns this BigInt as an int.
BigInt.toInt() returns value of type int
.
In this example,
bigInt
with a value of 123456789
.toInt()
method to convert it to an integer.void main() {
BigInt bigInt = BigInt.from(123456789);
int intValue = bigInt.toInt();
print('Converted value to int: $intValue');
}
Converted value to int: 123456789
In this example,
bigInt
with a value of -987654321
.toInt()
method to convert it to an integer.void main() {
BigInt bigInt = BigInt.from(-987654321);
int intValue = bigInt.toInt();
print('Converted value to int: $intValue');
}
Converted value to int: -987654321
In this Dart tutorial, we learned about toInt() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.