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

Null check operator used on a null value - wrong use of markdown #1926

Open
1 task done
geweald opened this issue May 23, 2024 · 3 comments · May be fixed by #1954
Open
1 task done

Null check operator used on a null value - wrong use of markdown #1926

geweald opened this issue May 23, 2024 · 3 comments · May be fixed by #1954
Assignees
Labels
bug Something isn't working

Comments

@geweald
Copy link
Contributor

geweald commented May 23, 2024

Which packages are you using?

stream_chat_flutter

On what platforms did you experience the issue?

Web, Windows, MacOS, Linux

What version are you using?

Latest

What happened?

When you are on web and click on a message text or start selecting text you get spam of Null check operator used on a null value errors in the browser console
Sometimes the text selection misbehave because of that too

Steps to reproduce

1. Open chat on web
2. Open dev tools console
3. Try to select text in the message bubble

Supporting info to reproduce

This is an issue with use MarkdownBody inside stream_chat_flutter/lib/src/message_widget/message_text.dart

The flutter_markdown docs has this sections:
image

Yet StreamMessageText sets selectable to true for web and desktop, but the onTapText and onSelectionChanged are never set, which causes the error to be thrown.

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@geweald geweald added the bug Something isn't working label May 23, 2024
@esarbanis
Copy link
Contributor

Hi @geweald

We are using flutter_markdown 0.6.17+1, in this version's documentation there is no Selection section. Furthermore, I cannot reproduce this error in our example project. Have you overridden this dependency in your project?

Also the selectable field is used to create a SelectableText.rich which has onTap and onSelectionChanged optional, so I am not really sure how this could produce a Null check operator used on a null value error.

@geweald
Copy link
Contributor Author

geweald commented Jun 10, 2024

I see, your dependency is not an exact version but flutter_markdown: ^ so it accepts the higher versions, so even when we're not overriding this but create a fresh project, pubspec will fetch the latest matching version which is not compatible (checked now your example project and it fetched flutter_markdown 0.6.23 in pubspec.lock)

So clone the repo, run example app on chrome, open chat, try to select text in any message, or tap the text etc. -> bunch of errors in the dev console Null check operator used on a null value

@deven98
Copy link
Contributor

deven98 commented Jun 17, 2024

Hi @geweald 👋

Thanks for bringing this to our attention. I've launched a PR that should fix this.

Feel free to reopen this if the error reoccurs. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants