Declaring async functions

An async function is a function whose body is marked withthe async modifier.

Adding the async keyword to a function makes it return a Future.For example, consider this synchronous function,which returns a String:

  1. String lookUpVersion() => '1.0.0';

If you change it to be an async function—for example,because a future implementation will be time consuming—thereturned value is a Future:

  1. Future<String> lookUpVersion() async => '1.0.0';

Note that the function’s body doesn’t need to use the Future API.Dart creates the Future object if necessary.If your function doesn’t return a useful value,make its return type Future<void>.

For an interactive introduction to using futures, async, and await,see the asynchronous programming codelab.