feat(GetX): update controller on tag change and add corresponding test#3441
Open
Danilospano00 wants to merge 1 commit intojonataslaw:masterfrom
Open
feat(GetX): update controller on tag change and add corresponding test#3441Danilospano00 wants to merge 1 commit intojonataslaw:masterfrom
Danilospano00 wants to merge 1 commit intojonataslaw:masterfrom
Conversation
SteveHawes
added a commit
to SteveHawes/getx
that referenced
this pull request
Feb 25, 2026
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.
Fix: Handle tag changes in GetX widget lifecycle
Description
This PR fixes a bug in the
GetXwidget where changes to thetagparameter during widget updates were not properly handled.Before: When the
tagparameter changed indidUpdateWidget, the widget would continue using the controller associated with the old tag, causing inconsistent behavior and potential memory leaks.After: The widget now properly detects tag changes and handles the transition by cleaning up the old controller and re-initializing with the new tag.
Changes Made
Modified:
lib/get_state_manager/src/rx_flutter/rx_getx_widget.dartdidUpdateWidgetto detect when thetagparameter changesautoRemoveis enabledinitState:Added:
test/state_manager/getx_widget_tag_update_test.dartWhy This Change Is Needed
When building dynamic UIs where the same
GetXwidget needs to switch between different controller instances (e.g., in a list or tabs), the tag parameter allows selecting which controller to use. Without this fix, changing the tag would not update which controller the widget listens to, breaking reactivity and potentially causing memory leaks from undisposed subscriptions.This brings the
didUpdateWidgetlifecycle method in line with the initialization logic, ensuring consistent behavior throughout the widget's lifecycle.Pre-launch Checklist
///).