2000calories / flutter_easy_rich_text

The EasyRichText widget provides an easy way to use RichText.
https://pub.dev/packages/easy_rich_text
MIT License
79 stars 34 forks source link

special characters don't take effect! #36

Closed Espero1995 closed 2 years ago

Espero1995 commented 2 years ago

I found that after setting hasSpecialCharacters: true, the original matching ordinary characters did not take effect, and the special symbols were not set to the highlighted state.

2000calories commented 2 years ago

Can you post an example?

Espero1995 commented 2 years ago

Like . - image

image
Espero1995 commented 2 years ago

是因为特殊字符串和其他字符连续的原因嘛?我对特殊字符后面加空格好像就能正常高亮显示了。在已解决的issue里我看到的电话号码99+的是因为后面有个空格,所以才高亮了,但是我去掉空格发现也是没有高亮的

2000calories commented 2 years ago
    EasyRichText(
      "Received 1-1-2 messages. Received 1.1.2 messages.",
      patternList: [
        EasyRichTextPattern(
          targetString: '1-',
          matchWordBoundaries: false,
          style: const TextStyle(color: Colors.red),
        ),
      ],
    ),

    EasyRichText(
      "Received 1-1-2 messages. Received 1.1.2 messages.",
      patternList: [
        EasyRichTextPattern(
          targetString: '1.',
          hasSpecialCharacters: true,
          matchWordBoundaries: false,
          style: const TextStyle(color: Colors.red),
        ),
      ],
    ),

要在 1-1-2 连续的字符串中匹配部分字符串1-,要设置matchWordBoundaries: false,

Espero1995 commented 2 years ago

OK了,非常感谢