Skip to content

Fix timer button negative countdown bug and enhance example app#34

Merged
ProjectAJ14 merged 1 commit intomainfrom
fix/timer-button-negative-countdown
Mar 23, 2026
Merged

Fix timer button negative countdown bug and enhance example app#34
ProjectAJ14 merged 1 commit intomainfrom
fix/timer-button-negative-countdown

Conversation

@ProjectAJ14
Copy link
Contributor

Summary

  • Fix negative countdown bug: Clamp timeOutInSeconds to 0 when negative, preventing display of values like "-5s"
  • Fix double-decrement on reset: Cancel pending timer before resetting counter in _onPressed, preventing a spurious extra tick
  • Add guard in _updateTime: Early return when counter is already <= 0
  • Code cleanup: Extract _safeTimeout getter to deduplicate clamping, remove unnecessary async on timer callback
  • Add 2 new tests: Verify negative timeOutInSeconds input is clamped and counter never goes below 0
  • Enhance example app: Restructure into app.dart, home_page.dart, theme.dart with Material 3 theming

Closes #24

Test plan

  • All 33 existing + new tests pass (flutter test)
  • flutter analyze passes with no issues
  • Manual: verify timer button shows "0s" (not "-5s") with negative timeOutInSeconds
  • Manual: verify button enables immediately when timeOutInSeconds is negative
  • Manual: verify example app renders with Material 3 theme in both light/dark modes

🤖 Generated with Claude Code

Closes #24

- Clamp timeOutInSeconds to 0 when negative, preventing display of
  negative countdown values like "-5s"
- Cancel pending timer before reset to prevent double-decrement bug
- Add guard in _updateTime to reject non-positive counter values
- Extract _safeTimeout getter to deduplicate clamping logic
- Remove unnecessary async on timer callback
- Add tests for negative timeOutInSeconds and counter clamping
- Restructure example app into app.dart, home_page.dart, theme.dart
- Upgrade example app to Material 3 theming with ColorScheme

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
dzod ?
html_rich_text ?
morse_tap ?
ns_intl_phone_input ?
ns_utils ?
timer_button 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/timer_button/lib/timer_button.dart 100.00% <100.00%> (ø)

... and 63 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ProjectAJ14 ProjectAJ14 merged commit d128676 into main Mar 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix timer button negative countdown bug and enhance example app

1 participant