Skip to content

Conversation

@gspencergoog
Copy link
Contributor

Description

This adds a delegate class that can override the transform used by a CompositedTransformFollower so that it can incorporate additional information other than the alignments and leader/follower sizes at the time of the transform.

I needed this in order to do cascading menus properly so that they wouldn't be delayed by a frame when their connected menu button moved.

Tests

  • Added a test to make sure that the delegate gets used and gets passed the correct information.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Sep 21, 2022
@gspencergoog gspencergoog force-pushed the follower_layer_delegate branch from a1a86ec to ada528f Compare September 21, 2022 20:58
@gspencergoog gspencergoog marked this pull request as ready for review September 21, 2022 20:59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering: Can this just be specified on RenderFollowerLayer/CompositedTransformFollower as a callback instead of requiring a subclass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it could be. My reasoning on this was that the word "transform" in the name meant that we could someday add scaling or rotation to the transformations in addition to offsets, and then it seemed like you'd want to have one subclass instead of multiple callbacks.

Also, for my use case, it was helpful for it to be a subclass that could hold state used to compute the offset, and if it was just a callback, I'd have to make a class anyhow to hold the state and keep the instance somewhere and pass a call to that object's function for computing it, so this was easier for my use case, which makes a weak case (weak because of a sample size of 1) that this would be useful for others too.

@gspencergoog gspencergoog force-pushed the follower_layer_delegate branch from f12b1ce to d73cf4c Compare September 22, 2022 22:28
@gspencergoog
Copy link
Contributor Author

Closing this, since we decided that we can't use this for my use case anyhow, since I need to do layout when the menus change location, and this won't allow that.

We're going to wait to add API for when there's a use case for it.

That said, this could be a useful thing to add if someone needs something similar in the future where positioning is all that is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants