bensonarafat / super_tooltip

SuperTooltip It is super flexible and allows you to display ToolTips in the overlay of the screen.
https://pub.dev/packages/super_tooltip
MIT License
142 stars 96 forks source link

Is there a way to set the offset for the tooltip? #106

Open Neicul123 opened 4 months ago

Neicul123 commented 4 months ago

Hi!

Thanks a lot for creating and maintaining this package. It seems great so far, but I'm running into a small issue:

The tooltip is always centered on the child widget, and no tap to dismiss is possible on half of the child due to this. In the screenshot you can see the area of the tooltip arrow preventing the dismissal. If I set the arrow size to 0, it sadly does not help, as the tooltip itself just gets put where the arrow was (at the center).

Screenshot 2024-07-15 at 00 12 42

I did some quick digging in the code, and saw a verticalOffset parameter, which seems to be what I'm searching for, but it's commented out and doesn't influence anything at the moment I think.

Is there any other way I can add some offset, or get the click/tap to go through that region as well? Thanks in advance!

KennedyChiang commented 4 months ago

Hi @Neicul123, I faced the same issue and came up with a workaround.

Original:

SuperTooltip(
    controller: superTooltipController,
    popupDirection: TooltipDirection.up,
    ...
    ...
    child: TargetWidget(),
),

The SuperTooltip would always place the arrow in the middle of the widget.

I just added a SizedBox.shrink() as my TargetWidget and wrapped it in a Row or Column, depending on the TooltipDirection.

Example below:

Row(
    children: [
        SuperTooltip(
            controller: superTooltipController,
            popupDirection: TooltipDirection.up,
            ...
            ...
            // Temporary workaround to address the issue where SuperTooltip obstructs part of the touch area for some of buttons.
            child: const SizedBox.shrink(),
        ),
        TargetWidget(),
    ],
),

This way, the SuperTooltip will never obstruct part of the touch area on the TargetWidget.

It’s not a great solution, but it works. 😅

bensonarafat commented 3 months ago

@Neicul123 I will look into the verticalOffset, if @KennedyChiang solution works for you consider that. When I have enough time. I will look into it.

Neicul123 commented 3 months ago

@KennedyChiang Thanks, that seems to work! Appreciate it!

@bensonarafat Thanks as well!