different ways of using future

1.

void main() async {
  var result = await Future.delayed(Duration(seconds: 10), () => 100);
  print("Result: $result");
}

2.

Future<int> getFutureResut() {
  return Future.delayed(Duration(seconds: 5), () => 100);
}

void main() async {
  print("Result: ${await getFutureResut()}");
}

3.

void printFutureResult() {
  var result = 100;
  Future.delayed(Duration(seconds: 10), () {
    print("Result: ${result}");
  });
}

void main() {
  printFutureResult();
}


Comments