• 1. Async decorated methods (code blocks) that return a Future instance by default
  • 2. Await must be used in async decorated methods
  • 3. The method that suspends an ‘await’ statement inside the async method is actually generating a future
  • 4. Future or async await, both of which place the event it decorates into the system’s event queue to be executed at an indefinite time in the future.
  • Let me give you an example just to make it easier to understand
testA() async {
    print("start");
    await testB();
    print("over");
}

testB() async{
    print("B");
}
Copy the code

The output of the above code is start, B, over. Await splits the code in two, and the code in method testA is equivalent to the following

testA() async{

  Future((){
    print("start");
    testB();
  }).then((_){
    print("over");
  });

}
Copy the code

Change the testB code above

testB() async{

  Future((){
    print("B");
  });

}
Copy the code

The output is start,over,B. Because the output of B is put into the Event queue for the event loop to pick it up and execute. If you want to make over the final output without getting rid of the Future in testB, you should go down like this

testB() async{// here add await await Future((){print("B");
  });

}
Copy the code

So its output becomes start, B, over again.