:::

6-16 倒數計時做某件事

class _ApplyDetailState extends State<ApplyDetail> {
  bool _show = true;
  Timer _timer;
  int count=3;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
      if(count==0) {
        _timer.cancel();
        _show = false;
        setState(() {
          count;
        });
        return;
      }
      count--;
    });
  }
  ...略...
}

 


:::

書籍目錄

展開 | 闔起

https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D42%26tbdsn%3D1914

計數器

今天: 3197319731973197
昨天: 4771477147714771
總計: 5539200553920055392005539200553920055392005539200