desconexo / highlight_text

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

First word in text not matching #15

Closed mamirix closed 3 years ago

mamirix commented 3 years ago

it's not matching for first word in text

Screen Shot 2021-09-01 at 4 32 38 PM

. I believe the error is caused by the statement in line 80 in highlight_text.dart. strIndex should be compared to ">= 0"

if (strIndex > 0) bindedText = bindedText.replaceRange(strIndex, strIndex + word.length, '${words.keys.toList().indexOf(word)}');

desconexo commented 3 years ago

"Mohib" is different than "mohib", so you must use enableCaseSensitive: true to work like you want. If you're already using enableCaseSensitive: true then it's a bug and I'll work on it tonight. Thank you.

desconexo commented 3 years ago

https://github.com/desconexo/highlight_text#100-breaking-changes

desconexo commented 3 years ago

Actually, you must use enableCaseSensitive: false (its default value is false). I now it's confusing, I'll rework this in the next update.

desconexo commented 3 years ago

Yes, you're right. The problem is the if statement