if I set the triggerMode to tap, the tooltip remains open until you tap somewhere else. The ShowDuration is ignored. To remedy this, I put a GestureDetector around it (which I don't think is such a nice solution). Does anyone know maybe a better solution to the problem.
class CustomTooltip extends StatefulWidget {
const CustomTooltip({
Key? key,
required this.tooltip,
this.padding = const EdgeInsets.only(left: kSpacingS),
}) : super(key: key);
final String tooltip;
final EdgeInsets padding;
@override
State<CustomTooltip> createState() => _CustomTooltipState();
}
class _CustomTooltipState extends State<CustomTooltip> {
GlobalKey _toolTipKey = GlobalKey();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () async {
final dynamic _toolTip = _toolTipKey.currentState;
_toolTip.ensureTooltipVisible();
await Future.delayed(const Duration(seconds: 5));
_toolTip.deactivate();
},
child: Padding(
padding: widget.padding,
child: Tooltip(
key: _toolTipKey,
// triggerMode: TooltipTriggerMode.tap,
padding: const EdgeInsets.all(kSpacingM),
margin: const EdgeInsets.all(kSpacingL),
showDuration: const Duration(seconds: 5),
message: widget.tooltip,
decoration: BoxDecoration(
color: CColor.blueDark.withOpacity(0.9),
borderRadius: const BorderRadius.all(Radius.circular(kSpacingXS)),
),
textStyle: const TextStyle(color: Colors.white, fontSize: 20),
// TODO ui
child: const Icon(Icons.info_outline),
),
),
);
}
}