GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
880 stars 313 forks source link

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

Open geweald opened 1 month ago

geweald commented 1 month ago

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

esarbanis commented 3 weeks ago

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 commented 2 weeks ago

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 commented 1 week ago

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!