Skip to content

Commit

Permalink
feat: Make limit field mutable in the Timer class (#2358)
Browse files Browse the repository at this point in the history
As stated in #2357, the field `limit` of the class `Timer` had no reason
to be final. By removing this keyword, we make it possible to add more
time to a given `Timer` object (so that they can be used as a countdown
for example).
  • Loading branch information
Skyost authored Feb 21, 2023
1 parent ecea916 commit 4e0a8c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/flame/lib/src/timer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import 'dart:ui';
/// interval like events.
///
/// Timer auto-starts by default.
///
/// NOTE: You can change the [limit], but keep in mind that the timer
/// won't start automatically if the limit is raised and the timer currently
/// is stopped.
class Timer {
final double limit;
double limit;
VoidCallback? onTick;
bool repeat;
double _current = 0;
Expand All @@ -19,7 +23,7 @@ class Timer {
bool autoStart = true,
}) : _running = autoStart;

/// The current amount of ms that has passed on this iteration
/// The current amount of seconds that has passed on this iteration
double get current => _current;

/// If the timer is finished, timers that repeat never finish
Expand Down

0 comments on commit 4e0a8c4

Please sign in to comment.