Implement RestartableTimer.tick (#89)
Closes #88
Extra cleanup:
- change a constructor body to an initializer list
- remove an `@override` annotation
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8436cd4..0b7518b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.3.0
+
+* Implement `RestartableTimer.tick`.
+
## 2.2.0
* Add `then` to `CancelableOperation`.
diff --git a/lib/src/restartable_timer.dart b/lib/src/restartable_timer.dart
index b8e414a..4720bcd 100644
--- a/lib/src/restartable_timer.dart
+++ b/lib/src/restartable_timer.dart
@@ -25,9 +25,8 @@
///
/// The [callback] function is invoked after the given [duration]. Unlike a
/// normal non-periodic [Timer], [callback] may be called more than once.
- RestartableTimer(this._duration, this._callback) {
- _timer = Timer(_duration, _callback);
- }
+ RestartableTimer(this._duration, this._callback)
+ : _timer = Timer(_duration, _callback);
bool get isActive => _timer.isActive;
@@ -44,11 +43,10 @@
_timer.cancel();
}
- @override
- // TODO: Dart 2.0 requires this method to be implemented.
- // See https://github.com/dart-lang/sdk/issues/31664
- // ignore: override_on_non_overriding_getter
- int get tick {
- throw UnimplementedError("tick");
- }
+ /// The number of durations preceding the most recent timer event on the most
+ /// recent countdown.
+ ///
+ /// Calls to [reset] will also reset the tick so subsequent tick values may
+ /// not be strictly larger than previous values.
+ int get tick => _timer.tick;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index d8ce61c..b1013ac 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: async
-version: 2.2.0
+version: 2.3.0
description: Utility functions and classes related to the 'dart:async' library.
author: Dart Team <misc@dartlang.org>