如何获得每个计时器计数值?飞镖颤振


void main() {
final newTi = Get.put(NewTimer());
...
...
...: Obx((){
return Text('${newTi.count}');
// I'm trying to set a new timer and watch each of them. 
// It's just 10. What should I do?
}),
}
//
//
class NewTimer extends GetxController {
RxInt count = 10.obs;
}
//
//
class TimerFunc extends GetxController {
void timeRun() {
NewTimer newTime = new NewTimer();
Timer.periodic(Duration(seconds: 1), (t) {
if (t.tick == 10) {
t.cancel();
} else {
newTime.count--;
}
});
}
}

我正试着设置一个新的计时器,看每一个。只有10。我该怎么办?

.........................................

getter?setter吗?在飞镖。

class NewTimer {
double _count;
NewTimer(this._count);
double get count => _count;
set count(double c) => _count = c;
}
void main() {
print(NewTimer(2.0).count);
print(NewTimer(3.0).count++);
}

最新更新