From 859b32d3420408abcf79ad6668d1b352ed6e9bb4 Mon Sep 17 00:00:00 2001 From: faiyaz Date: Mon, 30 Jan 2023 14:53:28 +0530 Subject: [PATCH] Tooltip position calculation update based on available window. From PR #288 --- lib/src/tooltip_widget.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/src/tooltip_widget.dart b/lib/src/tooltip_widget.dart index caaba8fc..5abbe7d0 100644 --- a/lib/src/tooltip_widget.dart +++ b/lib/src/tooltip_widget.dart @@ -118,10 +118,14 @@ class _ToolTipWidgetState extends State position.dy + ((widget.position?.getHeight() ?? 0) / 2); final topPosition = position.dy - ((widget.position?.getHeight() ?? 0) / 2); final hasSpaceInTop = topPosition >= height; + final EdgeInsets viewInsets = EdgeInsets.fromWindowPadding( + WidgetsBinding.instance.window.viewInsets, + WidgetsBinding.instance.window.devicePixelRatio); + final double actualVisibleScreenHeight = + (widget.screenSize?.height ?? MediaQuery.of(context).size.height) - + viewInsets.bottom; final hasSpaceInBottom = - ((widget.screenSize?.height ?? MediaQuery.of(context).size.height) - - bottomPosition) >= - height; + (actualVisibleScreenHeight - bottomPosition) >= height; return widget.tooltipPosition ?? (hasSpaceInTop && !hasSpaceInBottom ? TooltipPosition.top