Fix state update handling: Current page widgets do not receive update if the decorator marks the page as dirty #128
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
This Pull Request introduces an improvement to the state management within the WoltModalSheet package. Specifically, it addresses the scenario where the state update does not reflect on the modal sheet page due to unchanged page index yet with a new widget set provided.
Issue and Solution
Previously, when the root decorator widget, typically utilized as a ChangeNotifierProvider, updated the state, the new set of widgets associated with the same page index did not update the UI as expected. This was because the internal mechanism did not adequately mark the new widget set as "dirty" for rendering.
To resolve this, the PR implements a strategy where the incoming widget set is explicitly set to null following a state change. Subsequently, it forcibly rebuilds the current page set with the updated widgets. This ensures that the new state is accurately represented on the modal sheet page, even when the page index remains constant.
Impact
This change ensures that the UI reflects the current state without requiring a page index change. This enhancement is particularly crucial for applications where modal sheet content dynamically updates based on user interaction or other state changes without navigation between pages.
Performance Considerations
While this fix ensures the correctness of the UI, it is acknowledged that setting the widget set to null and rebuilding the entire page is not the most efficient approach. There is a planned comprehensive internal refactor to improve performance and address this inefficiency.
Testing
This change has been manually tested to ensure that the widget set updates correctly without requiring a page index change. Automated tests will be developed as part of the planned refactor to ensure no regression in the future.
state_no_update.mp4
state_update_after.mp4
Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?