The `toString` method of BigInt class in Dart converts an integer to its string representation.
The syntax of BigInt.toString() method is:
String toString()
This toString() method of BigInt returns a String-representation of this integer.
BigInt.toString() returns value of type String
.
In this example,
num
, initialized with an integer.toString
method to convert the BigInt to its string representation.void main() {
BigInt num = BigInt.from(12345);
String str = num.toString();
print('BigInt to string: $str');
}
BigInt to string: 12345
In this example,
num
, initialized with a negative integer.toString
method to convert the BigInt to its string representation.void main() {
BigInt num = BigInt.from(-98765);
String str = num.toString();
print('BigInt to string: $str');
}
BigInt to string: -98765
In this example,
num
, initialized with zero.toString
method to convert the BigInt to its string representation.void main() {
BigInt num = BigInt.from(0);
String str = num.toString();
print('BigInt to string: $str');
}
BigInt to string: 0
In this Dart tutorial, we learned about toString() method of BigInt: the syntax and few working examples with output and detailed explanation for each example.