myanmarlinks
5/31/2019 - 4:12 PM

Async and Await in Dart

Async and Await in Dart

void main() {
    var testAsync = TestAsync();
    testAsync.printWithDelay("Hello Async Dart!");
}

class TestAsync {
  static const fiveSecond = Duration(seconds: 5);

  Future<void> printWithDelay(String message) async {
    await Future.delayed(fiveSecond);
    print(message);
  }  
}