Futures

Basics
Good example
import 'dart:io';
void anotherJob() {
print('u know stuff and that');
}
Future<int> working() async {
print('working');
int a = 0;
await Future.delayed(Duration(seconds: 2), () {
print('done');
a = 1;
});
return a;
}
void done(int a) {
print(a);
}
void main() async {
working().then((value) {
done(value);
});
anotherJob();
}await - put this in front of a async function
async - you put this in the function definition
Pass in lambda functions as args into the following for each scenario
final myFuture = Future<int>.delayed(
Duration(seconds: 1),
() => 42,
)
.then(
(value) => print('Value: $value'),
)
.catchError(
(Object error) => print('Error: $error'),
)
.whenComplete(
() => print('Future is complete'),
);Asynchronous Network Requests