Please upvote: https://github.com/dart-lang/sdk/issues/40198
I am wondering how I can get access to the value of a future, while debugging in vs-code? Right now i need to introduce another temp variable to get the debugger to await the statement. This is how I am accessing a value at the moment:
Future<void> disconnect2() async {
var conn = await isConnected;
if (conn) await internalDisconnect();
}
But I would like to write the following:
Future<void> disconnect() async {
if (await isConnected) await internalDisconnect();
}
And still be able to access the value of isConnected with the debugger.
What I tried so far:
Try to add the expression (await isConnected) to the watch.
Tried to evaluate the expression (await isConnected) in the debug console.
Try to add the expression isConnected to the watch.
Tried to evaluate the expression isConnected in the debug console.
Tried to access the value through hovering over the instance. In the screenshot it is null, but most of the time I get to access only the future object.

Is there any easy way to access the value of a future while debugging?
You cannot see the value of future value while it is not awaited and loaded. The reason for it, future type is waiting the data, so it reserve part of memory for future value. You can access it only after getting the value f.e. value from REST API. You can use then method and see the value there.
someFuture(arg).then((erg) => print(erg));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With