The parameter 'chatmessage' can't have a value of 'null' because of its type, but the implicit default value is 'null'

I am currently using the dash_chat package to implement chat functionality in my app, but facing this issue:

The parameter 'chatmessage' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
Try adding an explicit non-'null' default value.

My code looks like this:

messageImageBuilder: (url, [chatmessage]) => Container(
  height: 200,
  width: 200,
  child: PhotoView(
    imageProvider: NetworkImage(url!),
  ),
),

>Solution :

Mention the parameter chatmessage with type ChatMessage?.

Your code should be like..

messageImageBuilder: (url, [ChatMessage? chatmessage]) => Container(
  height: 200,
  width: 200,
  child: PhotoView(
    imageProvider: NetworkImage(url!),
  ),
),

Leave a Reply