[two_dimensional_scrollables] added child position getter
Fixes [two_dimensional_scrollables] childPositionGetter in Tableview.builder #148141
https://github.com/flutter/packages/assets/61263149/bdd133b8-a546-4d81-900f-e6e53ff1b604
Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
- [] I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use
dart format.) - [x] I signed the [CLA].
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I [linked to at least one issue that this PR fixes] in the description above.
- [ ] I updated
pubspec.yamlwith an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes]. - [ ] I updated
CHANGELOG.mdto add a description of the change, [following repository CHANGELOG style]. - [x] I updated/added relevant documentation (doc comments with
///). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt].
- [x] All existing and new tests are passing.
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).
If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?
Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.
@Piinks There's a problem with this PR below are the follwoing details:
- Issue: PR has a problem regarding scrolling too fast.
- Specific Problem: Missing values, particularly at the top edge of the viewport.
- Example: When view is out of the viewport, expected value by childPositionGetter should be 0.0, but actual value obtained is 0.2.
- Solution Goal: Ensure correct values are obtained even when outside the viewport.
- Proposed Action: Implement measures to prevent this situation, guaranteeing accurate values retrieval.
Please let me know your thoughts on this. Thanks in adavnce.
Hi @Piinks,
Thanks for your response,
what is the problem you are trying to solve here?
The problem I am trying to solve is to determine the position of an element inside the viewport, which is crucial for developers when creating UIs that are otherwise not possible to achieve.
In the video linked below, to create such UIs where we need to know the position of a widget in the viewport (see the spot price in the video), it's mandatory to determine the position of a child element. Based on that position, we can perform various actions, in this case making the element stick to the top or bottom.
https://github.com/flutter/packages/assets/61263149/ba67cc15-29f3-403a-ad44-511fbcfb952a
would it be better to have a getChildOffset type method in the core 2D scrolling classes in the framework? Rather than just in the TableView?
you raise a great point. While I'm not an expert on the framework's internals, having a getChildOffset type method in the core 2D scrolling classes rather than just in the TableView could be incredibly beneficial. This feature would likely provide more flexibility and power to developers.
Thanks in advance.
Would you like to work on sending a PR that adds the method to the core TwoDimensionalViewport class? What should we do with this PR?
Would you like to work on sending a PR that adds the method to the core TwoDimensionalViewport class? What should we do with this PR?
Thank you for the opportunity to contribute! I am interested in working on adding the method to the core TwoDimensionalViewport class. However, I would appreciate some references to help me approach this problem effectively. Specifically, I'd need guidance on the following:
- Any documentation or pointers to key parts of the codebase that are relevant to this method in TwoDimensionalViewport.
- Implementation Guidelines: Best practices or examples of similar methods added to core classes in the past.
With these references, I will be able to contribute more efficiently. Thank you!
I am not sure where we might put the method, maybe RenderTwoDimensionalViewport? The contributing guide should be a good place to start as far as the guidelines you asked about: https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md Should we close this PR then?
From triage: what's the status of this PR? Was the conclusion that this should be closed in favor of a different solution?
Converting to a draft since there are unanswered questions about the approach; please mark as ready for review once that has been resolved.
I think this is safe to close as we will implement this in the framework instead.