From 6ac0ee50444442bede74ca397de374d5c36d092c Mon Sep 17 00:00:00 2001 From: Erick Parise Vitorassi Date: Wed, 30 Nov 2022 18:46:19 -0300 Subject: [PATCH] Add navigator ancestor to Offset This is needed to work correctly inside a RouterOutlet, flutter DropdowButton implements this --- lib/src/just_the_tooltip.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/just_the_tooltip.dart b/lib/src/just_the_tooltip.dart index bb7c22b..ce6606b 100644 --- a/lib/src/just_the_tooltip.dart +++ b/lib/src/just_the_tooltip.dart @@ -748,9 +748,13 @@ abstract class JustTheTooltipState extends State 'Cannot find the box for the given object with context $context', ); } - + + final navigator = Navigator.of(context); final targetSize = box.getDryLayout(const BoxConstraints.tightForFinite()); - final target = box.localToGlobal(box.size.center(Offset.zero)); + final target = box.localToGlobal( + box.size.center(Offset.zero), + ancestor: navigator.context.findRenderObject(), + ); // TODO: Instead of this, change the alignment on // [CompositedTransformFollower]. That way we can allow a user configurable // alignment on where the tooltip ends up.