随笔分类 -  dart

dart语言
摘要:一,代码: 说明: 使用async关键字,你可以在函数内部使用await关键字来等待另一个异步操作的完成,而不会阻塞当前线程的执行。 Future<String> getMyName() { //await Future.delayed(Duration(seconds: 2)); //函数内部不能 阅读全文
posted @ 2026-03-08 13:01 刘宏缔的架构森林 阅读(2) 评论(0) 推荐(0)
摘要:一,代码: Future<String> getMyName() { return Future.delayed(Duration(seconds: 2), () => '老孟'); } void myclick() async{ //错误得到Future类型返回 var name = getMyN 阅读全文
posted @ 2026-03-08 12:32 刘宏缔的架构森林 阅读(3) 评论(0) 推荐(0)
摘要:一,代码: //每1秒打印一下当前数字 void tick10() async { for (int i = 1; i <= 10; i++) { await Future.delayed(Duration(seconds: 1),(){ print("tick"+i.toString()); }) 阅读全文
posted @ 2026-03-08 10:44 刘宏缔的架构森林 阅读(1) 评论(0) 推荐(0)
摘要:一,代码 void myclick() async{ print("a"); //await tells dart to wait till this completes. // If it's not used before a future, // then dart doesn't wait 阅读全文
posted @ 2026-03-07 22:16 刘宏缔的架构森林 阅读(1) 评论(0) 推荐(0)