Flutter - Create a countdown widget

前端 未结 5 1970
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 20:58

I am trying to build a countdown widget. Currently, I got the structure to work. I only struggle with the countdown itself. I tried this approach using the countdown plugin:

5条回答
  •  猫巷女王i
    2021-02-05 21:48

    based on @raju-bitter answer, alternative to use async/await on countdown stream

      void countdown() async {
        cd = new CountDown(new Duration(seconds:4));
        await for (var v in cd.stream) {
          setState(() => val = v.inSeconds);
        }
      }
    

提交回复
热议问题