Skip to content

fix: add mounted check in _startHideTimer to prevent setState after dispose#940

Merged
diegotori merged 1 commit intofluttercommunity:masterfrom
Cleparr:fix/start-hide-timer-mounted-check
Mar 11, 2026
Merged

fix: add mounted check in _startHideTimer to prevent setState after dispose#940
diegotori merged 1 commit intofluttercommunity:masterfrom
Cleparr:fix/start-hide-timer-mounted-check

Conversation

@Cleparr
Copy link
Contributor

@Cleparr Cleparr commented Mar 11, 2026

Problem:
_startHideTimer calls setState inside a Timer callback without checking mounted first. If the widget is disposed before the timer fires (e.g. user navigates away), this causes a fatal crash: Null check operator used on a null value.

Fix:
Add if (!mounted) return; before setState, following the same pattern already used in _bufferingTimerTimeout and _updateState (PR #470).

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 43.82%. Comparing base (d228479) to head (bec9326).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/material/material_controls.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #940      +/-   ##
==========================================
- Coverage   43.84%   43.82%   -0.03%     
==========================================
  Files          21       21              
  Lines        1601     1602       +1     
==========================================
  Hits          702      702              
- Misses        899      900       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Copy link
Collaborator

@diegotori diegotori left a comment

Choose a reason for hiding this comment

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

LGTM.

@diegotori diegotori merged commit 7005a65 into fluttercommunity:master Mar 11, 2026
3 of 5 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.

2 participants