I have recently seen some code example like below
Future<Null> ensureLogin() {...}
var login = ensureLogin();
Future functionA() async {
await login;
print("FunctionA finished");
}
Future functionB() async {
await login;
print("FunctionB finished");
}
void main() {
functionA();
functionB()
}
When the future completed, it prints out below:
FunctionA finished
FunctionB finished
Looks like we can have multiple await for the same future object? But how does this work under the hood? And what is it equivalent to Future? Maybe something like below?
login.then(functionA).then(fucntionB)