-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make callbacks fire before future #49
base: main
Are you sure you want to change the base?
Conversation
I won't really get to this until after the holiday but what do you think about the onShow getting passed the state the tooltip is in? Something like: onShow: (state) {
switch (state) {
case TooltipState.start:
//
case TooltipState.end:
//
}
} That or we could even pass through the controller state as it's a value notifier with the state anyways. Another option would be to just add two more callbacks of I'm open to the Thank you for the PR too ! |
All these options seem good, a lot of the Flutter first party widgets will have a simple (also obviously no rush on this, I actually ended up cutting the feature in my app that required tool tips anyway) P.S. happy holidays! |
|
||
final completer = Completer<void>(); | ||
final future = completer.future.whenComplete(() { | ||
_removeEntries(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was some really weird behavior around the completers in _hideTooltip
and showTooltip
. Basically, hide and show were only kicking off the animation when they were first called and then setting the controller's status when the animation finished. Then, a listener on the animation status would see that it had changed and would call _hide
or _show
respectively a second time, this time with immediately = true
. The functions would then properly execute clean up logic under an if (immediately)
check. This was incorrectly firing the onShow
and onDismiss
callbacks twice.
I've fixed this by putting all the clean up logic in completer.complete()
so it's called by the immediate and non-immediate code paths and by adding a check at the top of each function to short circuit it if the tooltip is already in the desired state.
Currently, the
onShow
and theonDismiss
callbacks fire when their respective actions are completed, not when the actions start. This PR makes them fire on start.This is preferable because developers often want to trigger behavior on start (eg to play an animation in-step with the tooltip's show animation). They can't do this with the current design because their callback runs too late.
If developers want to trigger behavior when the tooltip animations finish, they can simply add a delay of the same duration as their animations to their callback: