fix(navigation): clamp navigateViewGroup viewIndex to valid tab range#2220
Closed
cursor[bot] wants to merge 1 commit into
Closed
fix(navigation): clamp navigateViewGroup viewIndex to valid tab range#2220cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Out-of-range viewIndex values caused RangeError when updating the global ViewGroupNotifier or calling PageController.jumpToPage. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
10 tasks
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 a crash when
navigateViewGroupis executed with onlyviewIndexand that index is outside the current ViewGroup menu (for example from evaluated YAML or bad app data). The action previously forwarded the raw index toPageController.jumpToPageandviewGroupNotifier.updatePage, which led toRangeErrorwhen indexingpagePayloadsduring rebuild.Related Issue
None filed; found by tracing
NavigateViewGroupActionvsPageGroupStateinitialization (which already clampsviewIndexfrompageArgs).Type of Change
What Has Changed
clampViewGroupTabIndexandviewGroupMenuItemCountForContextinpage_group.dartto bound indices using the nearestPageGroupancestor’s menu length.NavigateViewGroupActionnow clampsviewIndexbeforejumpToPage/updatePagewhen that ancestor is found.test/view_group_tab_index_clamp_test.dartfor the clamp helper.How to Test
modules/ensemble, runflutter test test/view_group_tab_index_clamp_test.dart.navigateViewGroupwithviewIndexset to N or higher (or negative); the app should switch to the last (or first) tab instead of throwing.Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passNote: The automation sandbox did not have
flutteronPATH; please runflutter test/flutter analyzelocally for the checklist items.Duplicate check
navigateViewGroup/viewIndex/ ViewGroup bounds work; no existing PR clamps this path. Related drafts (e.g. page header timers, upload path traversal, ListView scroll sync) address different root causes.NavigateViewGroupActionviewIndex.