Last active
March 21, 2021 18:16
-
-
Save cs118651/987eddf4e08c30334b09949a50eaa833 to your computer and use it in GitHub Desktop.
dart-async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
void main() { | |
Future getName() async { | |
// 打印时钟 | |
Timer.periodic(new Duration(seconds: 1), (timer) { | |
final tick = timer.tick; | |
print('时间过去$tick秒'); | |
if (tick >= 5) { | |
timer.cancel(); | |
} | |
}); | |
String name = await Future.delayed(Duration(seconds: 4), () => 'shuangyu'); | |
print(name); | |
} | |
getName(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment