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(" 此次为空");
                                          }
                                        });
                                      });

 

posted on 2018-07-20 18:50  --LP--  阅读(10731)  评论(0)    收藏  举报

导航