Asynchronous programming

Futures

Like JavaScript, Dart supports single-threaded execution. In JavaScript,
the Promise object represents the eventual completion (or failure)
of an asynchronous operation and its resulting value.

Dart uses Future objects to handle this.

// JavaScript

class

Example

_getIPAddress

()

const

url

https://httpbin.org/ip

return

fetch

url

then

response

=>

response

json

())

then

responseJson

=>

const

ip

responseJson

origin

return

ip

});

function