diff --git a/lib/widgets/shared/custom_tooltip.dart b/lib/widgets/shared/custom_tooltip.dart index 23c009a..678246f 100644 --- a/lib/widgets/shared/custom_tooltip.dart +++ b/lib/widgets/shared/custom_tooltip.dart @@ -41,8 +41,10 @@ class CustomTooltipState extends State { void _showTooltip() { _timer = Timer(widget.showDelay, () { - _overlayEntry = _createOverlayEntry(); - Overlay.of(context).insert(_overlayEntry!); + _overlayEntry ??= _createOverlayEntry(); + if (_overlayEntry != null) { + Overlay.of(context).insert(_overlayEntry!); + } }); _timeOut = Timer(const Duration(seconds: 2), () { @@ -54,7 +56,9 @@ class CustomTooltipState extends State { void _hideTooltip() { _timer?.cancel(); _timeOut?.cancel(); - _overlayEntry?.remove(); + if (_overlayEntry?.mounted == true) { + _overlayEntry?.remove(); + } _overlayEntry = null; } @@ -107,7 +111,9 @@ class CustomTooltipState extends State { ), ); - Overlay.of(context).insert(_overlayEntry!); + if (_overlayEntry != null) { + Overlay.of(context).insert(_overlayEntry!); + } } });