Skip to content

Instantly share code, notes, and snippets.

@Dalmangyi
Last active August 30, 2019 04:29
Show Gist options
  • Save Dalmangyi/f8d338addf1117c5886e3720c00fa4f7 to your computer and use it in GitHub Desktop.
Save Dalmangyi/f8d338addf1117c5886e3720c00fa4f7 to your computer and use it in GitHub Desktop.
Dart Future exam
import 'dart:async';
main() async {
countSeconds(4);
await message();
}
void countSeconds(s) {
for(var i=1; i<=s; i++ ) {
Future.delayed(Duration(seconds: i), () => print(i));
}
}
void message () async {
print('hi');
var name = await thinking();
print('bye $name');
}
Future<String> thinking() {
return Future.delayed(Duration(seconds: 4), () => 'Mr...Kim?');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment