Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added refreshTime parameter #38

Merged
merged 1 commit into from Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/stop_watch_timer.dart
Expand Up @@ -32,6 +32,7 @@ class StopWatchTimer {
this.isLapHours = true,
this.mode = StopWatchMode.countUp,
int presetMillisecond = 0,
int refreshTime = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.refreshTime = 1,

this.onChange,
this.onChangeRawSecond,
this.onChangeRawMinute,
Expand All @@ -40,6 +41,7 @@ class StopWatchTimer {
}) {
/// Set presetTime
_presetTime = presetMillisecond;
_refreshTime = refreshTime;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

_initialPresetTime = presetMillisecond;

if (mode == StopWatchMode.countDown) {
Expand Down Expand Up @@ -108,6 +110,7 @@ class StopWatchTimer {
int _startTime = 0;
int _stopTime = 0;
late int _presetTime;
late int _refreshTime;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final int refreshTime;

int? _second;
int? _minute;
List<StopWatchRecord> _records = [];
Expand Down Expand Up @@ -313,7 +316,7 @@ class StopWatchTimer {
void _start() {
if (!isRunning) {
_startTime = DateTime.now().millisecondsSinceEpoch;
_timer = Timer.periodic(const Duration(milliseconds: 1), _handle);
_timer = Timer.periodic(Duration(milliseconds: _refreshTime), _handle);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refreshTime

}
}

Expand Down