Skip to content

Commit

Permalink
Properly dispose timer for Countdown widget
Browse files Browse the repository at this point in the history
  • Loading branch information
vusters committed Jan 9, 2024
1 parent c00107f commit 83e86c5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/widget/countdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,23 @@ class CountdownController extends WidgetController {
CountdownAction? countdownAction;

TextStyleComposite? _textStyle;

TextStyleComposite get textStyle => _textStyle ??= TextStyleComposite(this);

set textStyle(TextStyleComposite style) => _textStyle = style;

TextStyleComposite? _labelStyle;

TextStyleComposite get labelStyle => _labelStyle ??= TextStyleComposite(this);

set labelStyle(TextStyleComposite style) => _labelStyle = style;
}

mixin CountdownAction on WidgetState<Countdown> {
void startTimer();

void stopTimer();

void resetTimer();
}

Expand Down Expand Up @@ -186,6 +192,12 @@ class CountdownState extends WidgetState<Countdown> with CountdownAction {
widget.controller.countdownAction = this;
}

@override
void dispose() {
_countdownTimer?.cancel();
super.dispose();
}

@override
void didUpdateWidget(covariant Countdown oldWidget) {
super.didUpdateWidget(oldWidget);
Expand Down

0 comments on commit 83e86c5

Please sign in to comment.