fluttercandies/extended_text

[Feature request]

Closed this issue · 1 comments

Platforms

Android, iOS, macOS, Web, Windows, Linux

Description

I'd love to see the draw line end at the end of the text, and not at the end of the container.

This is the current view:
Screenshot 2023-06-24 at 8 32 47 AM

It seems like it has to do with updating the value of rect.right to match the value of the last character on the line, but I am not finding that.

///top-right
            if (endOffset != null) {
              final Rect firstLineRect =
                  offset & Size(rect.right - offset.dx, painter.height);

              if (backgroundTextSpan.clipBorderRadius != null) {
                canvas.save();
                canvas.clipPath(Path()
                  ..addRRect(backgroundTextSpan.clipBorderRadius!
                      .resolve(painter.textDirection)
                      .toRRect(firstLineRect)));
              }

The value from the textRect, extends all the way to the end of the container, and doesn't just get to the end of the characters.

final Rect textRect = offset & painter!.size;

Why

This is a detail that better matches what is expected. Someone reading wants to see the highlighted text.

you can use BackgroundTextSpan and draw highlight base on your case