我正在嘗試構建倒計時部件。目前,我得到了結構工作。我只爲倒計時本身而奮鬥。我使用倒計時插件嘗試了這種方法:顫振 - 創建倒計時部件
class _Countdown extends State<Countdown> {
int val = 3;
void countdown(){
CountDown cd = new CountDown(new Duration(seconds: 4));
cd.stream.listen((Duration d) {
setState((){
val = d.inSeconds;
});
});
}
@override
build(BuildContext context){
countdown();
return new Scaffold(
body: new Container(
child: new Center(
child: new Text(val.toString(), style: new TextStyle(fontSize: 150.0)),
),
),
);
}
}
但是,值的變化非常奇怪,而且根本不平滑。它開始抽搐。任何其他方法或修復?
你能對你的時刻,詳細點嗎?你的代碼看起來如何? –
其實,我得到了工作的結構。唯一的問題是功能本身。我用Timer和countdown.dart插件試了一下。我會分享我的代碼 – OhMad
你是什麼意思怪異?你需要動畫嗎? –