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