:::

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--;
    });
  }
  ...略...
}

 


:::

書籍目錄

展開 | 闔起

快速登入


http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1914%26tbsn%3D42

計數器

今天: 1351135113511351
昨天: 8625862586258625
總計: 8031958803195880319588031958803195880319588031958