desconexo / highlight_text

A flutter plugin to highlight words from a text
MIT License
30 stars 22 forks source link

Highlighted words are raised #33

Closed crizant closed 2 years ago

crizant commented 2 years ago
Screen Shot 2022-09-20 at 11 47 29 AM

Maybe we should add alignment: PlaceholderAlignment.middle to the WidgetSpan?

crizant commented 2 years ago

In my own fork I changed WidgetSpan to TextSpan to fix vertical alignments, but in that case we can't add decoration and padding to the keywords:

return TextSpan(
    children: [
      TextSpan(
        text: showWord,
        style: words[currentWord]!.textStyle ?? textStyle,
        recognizer: TapGestureRecognizer()
          ..onTap = words[currentWord]!.onTap ?? () {},
      ),
      _buildSpan(boundWords),
    ],
  );
lauraldo commented 2 years ago

@crizant so where can I find your fork?

crizant commented 2 years ago

@crizant so where can I find your fork?

It’s in my working account. I made it at work so technically it’s not okay to share it publicly. Maybe you should make your own, the core change is in my previous comments.

desconexo commented 2 years ago

thank you. I cannot remove WidgetSpan, but I added a new argument to TextHighlight named spanAlignment, that you can set it to PlaceholderAlignment.middle