
DART Cookbook
By :

The Future
class from dart:async
lies in the basis of all asynchronous programming in Dart. A Future is, in fact, a computation that is deferred; it represents an object whose value will be available sometime in the future. It is not available immediately, because the function that returns its value depends on some kind of input/output and is, thus, unpredictable by nature. Here are some examples: a time-consuming computation, reading in a big dataset, and searching through a number of websites.
In the two previous chapters, quite a lot of recipes used Futures; in Chapter 6, Working with Files and Streams, we had the following recipes using Futures:
Reading and processing a file line by line
Concatenating files the asynchronous way
Downloading a file
In the preceding chapter, we used Futures in the following recipes:
Making a web server
Receiving data on the web server
Using sockets
In this chapter, we will concentrate on how to write elegant code for Futures and combine...
Change the font size
Change margin width
Change background colour