fix(page): cancel header poll timers and dedupe title bar storage listeners#2217
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(page): cancel header poll timers and dedupe title bar storage listeners#2217cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
PageState registered the same ModelChangeEvent listener three times for titleBarHeight storage updates, and never cancelled periodic Timers in dispose. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes lifecycle issues in
PageStatewhen optional header features attach storage-driven rebuild hooks: the title-bar height path accidentally registered the sameModelChangeEventlistener three times, and periodicTimerinstances were never cancelled indispose(). Both patterns waste work after navigation and increase the risk of callingsetStatewhile the page is tearing down.Related Issue
None filed; found during review of
Pageheader / device-metric code paths.Type of Change
What Has Changed
eventBus.on<ModelChangeEvent>().listenblocks in_listenToTitleBarHeightChangeswith a single subscription stored in_titleBarHeightStorageSubscription._headerVisibilityStorageSubscription(same pattern, single listener) and guarded callbacks withmountedwhere missing._setupPeriodicStorageCheck/_setupPeriodicVisibilityChecknow assign to_titleBarHeightPollTimer/_headerVisibilityPollTimer(cancelling any prior timer before replacing).dispose()cancels those subscriptions and timers before removing route observers and disposing the scope manager.How to Test
modules/ensemble, runflutter analyze lib/framework/view/page.dart.flutter test(or at least smoke tests) for the module.listenTitleBarHeightStorage/ collapsible header storage bindings, navigate away quickly, and confirm no exceptions from timers or event bus callbacks (sandbox here had no Flutter SDK onPATH).Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passDuplicate check
ListViewCore).titleBarHeight periodic,PageState Timer, and similar: no existing PR or branch fixing duplicated title-bar storage listeners or explicit cancellation of these page-level periodic timers.