Add an additional builder to DragTarget which fires on every Draggabl…#60174
Conversation
|
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 Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@HansMuller and/or @goderbauer PTAL (I can't seem to add reviewers). If the design is acceptable, I will add tests. |
dkwingsmt
left a comment
There was a problem hiding this comment.
Great job, especially adding these documentations!
Most of the comments are bike shedding.
|
Also, I see the demonstration in #58982 seems to have a one-frame delay between the dragged square and child square. Does this implementation have the same issue? |
b9dddd5 to
a3d3559
Compare
It does not. The commit implementation does a rebuild on move (for immediate updating of children) and also the onMove callback (for logic outside of the build tree) |
|
Having those two different builder on the widget is a very strange API that I would like to avoid. It seems unnecessary confusing to the user. Hence my suggestion if you can do what you want to do by just adding the |
I agree it's an unusual API. However, just using onMove() is not as ergonomic as something purely within a widget hierarchy. If I want to draw within the DragTarget while the Draggable moves, here's examples with the new callback, and with onMove: Example of new Example with Quick discussion of an alternative, consisting of all the following
. However, it would continue to only fire child rebuilds on Draggable enter/leave/drop/reject. Thanks for taking a look. |
|
I still think that just providing |
a3d3559 to
d078f1e
Compare
|
I've removed the additional builder function, and only added the onMove() callback. PTAL. |
There was a problem hiding this comment.
Maybe extract this out into a private method and call it below as well.
|
Not sure why the doc shard is failing. Maybe try rebasing this onto the latest master and try again? |
d078f1e to
e5b3d3e
Compare
|
Rebased on latest and more stuff is green. I don't know how to remove or resolve the requested review from @dkwingsmt, though. |
|
You're good to go with goderbauer's approval! :) |
|
This pull request is not suitable for automatic merging in its current state.
|
|
This pull request is not suitable for automatic merging in its current state.
|
…e movement within the DragTarget, and vends DragTargetDetails instead of Dragagble data.
Also adds an onMove callback on the DragTarget.
Description
-Adds an additional builder to DragTarget ("detailsBuilder") with a different signature. This additional builder is called on every move of a DragAvatar within the DragTarget, and vends DragTargetDetails (rather than just the raw data). This allows user to decide whether they want the existing behavior (rebuild on DragAvatar enter/leave/accept/reject), or additional behavior (rebuilt the same times as [builder], but also rebuilt on each move), in order to draw decorations for hovering draggables.
Note that the user must set either of the two builders; if both are set, the detailsBuilder is preferred and called.
-Adds an onMove callback, so that DragAvatar movement in the DragTarget can be handled outside of the build tree. This allows, for example, drawing outside the DragTarget or reporting movement to another widget.
Related Issues
Fixes #58982
Tests
I added the following tests:
Awaiting guidance on this design before adding additional tests to draggable_test (which will be part of this commit)
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.