-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single number as HighlightedWord causes error #19
Comments
I was also having issues when the first word of the text was a number and was highlighted. In my case, changing the way the index was parsed in Since the int? index;
// Only parse index if nextToDisplay doesn't have any leading or trailing whitespace
if (nextToDisplay.length == nextToDisplay.trim().length) {
index = int.tryParse(nextToDisplay);
} I've not tested this thoroughly, so YMMV. |
Another error case related to this issue is when the matching number word is a substring of a longer number: |
This has been fixed by #48, I think we don't have to pin it anymore? @desconexo |
This is a very useful package. Thank you for creating it!
I faced some issues in my work with it and I found work around, but since it might be useful for other users, I decided to document it.
To present overview of evaluation, I need to replace some substrings in a template message and to print them out with additional styling. For this task I use combination of ARB file and this package. All values are loading from API and I may receive null for some of them. Here are two issues I faced in my work:
with nullable keys:
I save nullable variables like this
final value = data?.toString() ?? '';
and it doesn't return compile error, but causes an ugly result.
Fix this with adding it with if statement - if(data != null) template: HighlightedWord(textStyle:...),
with single numbers:
If some of keys is number (like 0) it replaces substrings, witch have their own different key.
Example: "0's points didn't change. Current number of points is 0. 0 has changed technical seniority to Intern."
where replaced values are bold and instead of userName: HighlightedWord(textStyle:...), for customizing that value is used score: HighlightedWord(textStyle:...) where score = scoreValue.toString() and scoreValue = 0
Fix this with with adding empty space in front of the number character like this: score = ' ${scoreValue.toString()}'
Hopefully this information will be useful to others. And again: Thank you for creating this package!
The text was updated successfully, but these errors were encountered: