:::

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%3Ftbdsn%3D1914%26tbsn%3D42

計數器

今天: 3964396439643964
昨天: 2489248924892489
總計: 8025946802594680259468025946802594680259468025946