marcelogil / el_tooltip

Flutter tooltip widget with smart positioning
MIT License
26 stars 15 forks source link

Tooltip not rendering #7

Closed simplenotezy closed 1 year ago

simplenotezy commented 1 year ago

Hey - thanks for a great initiative.

I tried switching from "simple_tooltip" to your library, but I am having troubles rendering the tooltip to screen:

    return ElTooltip(
      child: widget.child,
      showModal: true,
      color: AppTheme.of(context).primary,
      content: GestureDetector(
        onTap: onDismiss,
        child: Body2(
          widget.tooltipText,
          color: Colors.white,
          settings: TextSettings(overflow: TextOverflow.clip),
        ),
      ),
    );

Not really sure what's going on.

The diff:


+import 'package:el_tooltip/el_tooltip.dart';
 import 'package:flutter/material.dart';
-import 'package:simple_tooltip/simple_tooltip.dart';

@@ -91,21 +91,17 @@ class _TooltipState extends ConsumerState<Tooltip> {
       return widget.child;
     }

-    return SimpleTooltip(
-      tooltipTap: onDismiss,
-      animationDuration: Duration(milliseconds: 250),
-      show: true,
-      tooltipDirection: TooltipDirection.up,
+    return ElTooltip(
       child: widget.child,
-      backgroundColor: AppTheme.of(context).primary,
-      borderWidth: 0,
-      customShadows: [],
-      targetCenter: widget.targetCenter,
-      ballonPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
-      content: Body2(
-        widget.tooltipText,
-        color: Colors.white,
-        settings: TextSettings(overflow: TextOverflow.clip),
+      showModal: true,
+      color: AppTheme.of(context).primary,
+      content: GestureDetector(
+        onTap: onDismiss,
+        child: Body2(
+          widget.tooltipText,
+          color: Colors.white,
+          settings: TextSettings(overflow: TextOverflow.clip),
+        ),
       ),
     );
marcelogil commented 1 year ago

Thanks for trying el_tooltip @simplenotezy

Were you able to make it work?

The simplest integration would be to just specify the child (normally the icon that trigger the tooltip) and the content (what appears inside the tooltip):

ElTooltip( content: Text('Hola Mundo!'), child: Icon(Icons.info), )

The library manages the tap, so you only need to insert the Widget you want to see. Try to start with a simple widget and add more things until it breaks. If it does, let me know.

Cheers Gil

simplenotezy commented 1 year ago

If it manages the tab, how do I specify the callback function? I'd like to do some custom logic on dismissal

simplenotezy commented 1 year ago

And no, didn't get it to work since posting the issue. Reverted back to old library (for now)

marcelogil commented 1 year ago

In that case we might need to trigger a callback function when the method void _hideOverlay() is triggered. Right now it's not available. Will let you know when I add it.

Thanks for the suggestion. :-)

simplenotezy commented 1 year ago

Sounds good! 💪