This pull request introduces a new boolean property showOnTap to the SuperTooltip widget, allowing developers to control whether the tooltip should be displayed when the child widget it wraps is tapped. This enhancement enables more flexible use cases, particularly when integrating with external state management solutions like BLoC.
New Functionality:
The showOnTap property supports the following three scenarios:
Tooltip shows when the child widget is tapped:
If showOnTap is set to true (default behavior), the tooltip will be displayed when the user taps the child widget.
Tooltip shows on both BLoC event triggers and child widget taps:
If showOnTap is true, the tooltip can be displayed either by tapping the child widget or by triggering a BLoC event that calls SuperTooltipController.showTooltip().
Tooltip shows only on BLoC event triggers:
If showOnTap is set to false, the tooltip will only be displayed when a BLoC event triggers it, and it will ignore any taps on the child widget.
Code Changes:
Added showOnTap Property:
The SuperTooltip widget now includes a showOnTap boolean property, which defaults to true to maintain backward compatibility.
Updated GestureDetector Logic:
The GestureDetector in the build method was updated to check the showOnTap value before attempting to show the tooltip when the child widget is tapped.
Backward Compatibility:
The default value of showOnTap is true, ensuring that existing implementations of SuperTooltip remain unaffected by this change. Developers can opt into the new functionality by explicitly setting showOnTap to false.
Testing:
The following test cases were covered:
Verifying that the tooltip displays as expected when showOnTap is true.
Ensuring that the tooltip does not display on tap when showOnTap is false and can only be shown via BLoC events.
Confirming that both tap and BLoC event triggers work as intended when showOnTap is true.
Summary:
This pull request introduces a new boolean property
showOnTap
to theSuperTooltip
widget, allowing developers to control whether the tooltip should be displayed when the child widget it wraps is tapped. This enhancement enables more flexible use cases, particularly when integrating with external state management solutions like BLoC.New Functionality:
The
showOnTap
property supports the following three scenarios:Tooltip shows when the child widget is tapped:
showOnTap
is set totrue
(default behavior), the tooltip will be displayed when the user taps the child widget.Tooltip shows on both BLoC event triggers and child widget taps:
showOnTap
istrue
, the tooltip can be displayed either by tapping the child widget or by triggering a BLoC event that callsSuperTooltipController.showTooltip()
.Tooltip shows only on BLoC event triggers:
showOnTap
is set tofalse
, the tooltip will only be displayed when a BLoC event triggers it, and it will ignore any taps on the child widget.Code Changes:
Added
showOnTap
Property:SuperTooltip
widget now includes ashowOnTap
boolean property, which defaults totrue
to maintain backward compatibility.Updated GestureDetector Logic:
GestureDetector
in thebuild
method was updated to check theshowOnTap
value before attempting to show the tooltip when the child widget is tapped.Backward Compatibility:
showOnTap
istrue
, ensuring that existing implementations ofSuperTooltip
remain unaffected by this change. Developers can opt into the new functionality by explicitly settingshowOnTap
tofalse
.Testing:
showOnTap
istrue
.showOnTap
isfalse
and can only be shown via BLoC events.showOnTap
istrue
.