flutter dart定时任务


首先:

  import 'dart:async';

直接上代码:

                                      new Future(() {
                                        getGameConfig("bi_da_xiao");
                                      }).then((_) {//此下划线提示getGameConfig方法的执行对下面的代码有重要影响(主要是这个参数:Game.game_config_value)
                                        var timer;
                                        timer = Timer.periodic(
                                            const Duration(milliseconds: 500), (Void) {
                                          if (Game.game_config_value != null) {

                                            (timer as Timer).cancel();

                                            print("main_app : " +
                                                Game.game_config_value
                                                    .toString());
                                            Navigator
                                                .of(context)
                                                .pushNamed("/game/bi_da_xiao");
                                          }else {
                                            print(" 此次为空");
                                          }
                                        });
                                      });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM