The `toString` method in Dart returns a string representation of this object.
The syntax of Future.toString() method is:
String toString()
This toString() method of Future returns a string representation of this object.
Future.toString() returns value of type String
.
In this example,
future
containing the value 42.toString()
method to obtain its string representation.void main() {
Future<int> future = Future<int>.value(42);
String futureString = future.toString();
print('String representation of Future object: $futureString');
}
String representation of Future object: Instance of 'Future<int>'
In this Dart tutorial, we learned about toString() method of Future: the syntax and few working examples with output and detailed explanation for each example.