Skip to content
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

Trim whitespace of hashtags in HashTagText onTap #35

Closed
EdwynZN opened this issue Oct 5, 2020 · 3 comments
Closed

Trim whitespace of hashtags in HashTagText onTap #35

EdwynZN opened this issue Oct 5, 2020 · 3 comments

Comments

@EdwynZN
Copy link

EdwynZN commented Oct 5, 2020

While using this package I found a weird behavior when returning a hashtag from the onTap

HashTagText(
    text: userText, // Ex: This is my first time using a #hashtag
    onTap: (hashtag) => Search.value(hashtag),
    overflow: TextOverflow.ellipsis,
    maxLines: 3,
),

If I tap on the hashtag I retrieve " #hashtag" with an empty space at the beggining (this doesn't happen if it's the first word).

If I use the method extractHashTags(userText) I get a list with the hashtags trimmed (I read the code at the end you use trim with every value). This gives some weird behavior when trying to save the list from extractHashTags and then finding the value selected by the onTap because the empty space at the beggining (using equality or saving the hashtags in a SQL or NoSQL db), I know I could do it myself onTap: (hashtag) => Search.value(hashtag.trim()) but it would be better for the package to return the same type in every method, which I believe doing the trimming could be a time saver to avoid different results

@santa112358
Copy link
Owner

@EdwynZN
Thank you for creating the issue.
Let me make it clear before I fix the problem. You mean the argument of onTap(hashtag) has unnecessary space and you think it should be trimmed, right? (If so, I agree.)

@EdwynZN
Copy link
Author

EdwynZN commented Oct 6, 2020

Yeah if the hashtag is not the first word the argument of onTap return the hashtag with an unnecessary left space

@santa112358 santa112358 mentioned this issue Oct 7, 2020
@santa112358
Copy link
Owner

@EdwynZN
I updated the version to 1.0.3 which solves the problem you told me.
https://github.com/santa112358/hashtagable/blob/master/lib/functions.dart#L69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants