我一直希望下面这样,但是显然这行不通。
Stopwatch watch = new Stopwatch();
watch.elapsed = watch.elapsed + Duration(hours: 01, minutes: 23, seconds: 31);
有什么方法可以达到预期的结果吗?
-感谢您提供任何提示/线索。
答案 0 :(得分:1)
Stopwatch
用于测量间隔-通常在性能测试中使用。也许您想要一个Timer
。或子类秒表。
Timer t = Timer(Duration(hours: 01, minutes: 23, seconds: 31), () {
print('time to take the cake out of the oven');
});
...
t.cancel(); // use this if you want to cancel the timer early
class OffsetStopwatch extends Stopwatch {
Duration offset;
OffsetStopwatch(this.offset);
Duration get offsetElapsed => offset + elapsed;
}