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
141 stars 95 forks source link

textscaling causes issues on centering #36

Closed tofutim closed 2 years ago

tofutim commented 2 years ago

when my text scale is 1.0, I get

image

as expected, but somehow when I increase the textscale, say to 2.0, I end up with the arrow no longer in the middle

image

hmm, in fact, it is pointing to .25, .25, instead of .5, .5 of the widget.

Update. It seems that "renderbox" gives the same size regardless of whether textscale is 2.0 or 1.0 which is the problem.

Update 2. https://github.com/flutter/flutter/issues/70885 "RenderObjects of WidgetSpan.child not scaled according to textScaleFactor #70885"; indeed I do have the text inside a WidgetSpan.

tofutim commented 2 years ago

I feel guilty doing this, but

    final postScaleSize = Size(renderBox.size.width * textScaleFactor,
        renderBox.size.height * textScaleFactor);

    _targetCenter = renderBox.localToGlobal(postScaleSize.center(Offset.zero),
        ancestor: overlay);

and

  ///
  /// TextScaleFactor when scaling text in WidgetSpan
  final double textScaleFactor;

did the trick for me.

image

tofutim commented 2 years ago

I bet it is possible to get the textScaleFactor if we can track back to the parent widgetspan...