Skip to content

Commit

Permalink
Merge pull request #1 from ErickPariseVitorassi/patch-1
Browse files Browse the repository at this point in the history
Add navigator as ancestor to Offset
  • Loading branch information
emirdeliz authored Dec 1, 2022
2 parents 6119d87 + 8b2fef2 commit 7496996
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.14

* Add `navigator.context.findRenderObject()` as ancestor to overlay position offset, this is needed to work correctly inside a RouterOutlet.

## 0.0.11

* Initial release.
6 changes: 5 additions & 1 deletion lib/src/menu_float.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ class _MenuFloatState<T> extends State<MenuFloat<T>>
/// Returns a MenuFloatIdealPosition.
MenuFloatIdealPosition _getWidgetPositionAndSizeRelativeToWindow(
BuildContext? menuKeyContext) {
final navigator = Navigator.of(context);
final RenderBox renderBox = menuKeyContext?.findRenderObject() as RenderBox;
final position = renderBox.localToGlobal(Offset.zero);
final position = renderBox.localToGlobal(
Offset.zero,
ancestor: navigator.context.findRenderObject(),
);
final double top = position.dy;
final double left = position.dx;
final double width = renderBox.size.width;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: menu_float
description: A menu float package to use on menu like tooltip, dropdown and etc.
version: 0.0.13
version: 0.0.14
homepage: https://github.com/emirdeliz/menu_float

environment:
Expand Down

0 comments on commit 7496996

Please sign in to comment.