参数 ‘chatmessage’ 不能为 ‘null’,因为它的类型不允许,但隐式默认值为 ‘null’

huangapple go评论95阅读模式
英文:

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

问题

以下是翻译好的内容:

"chatmessage" 参数不能为 "null",因为它的类型要求,但隐式默认值为 "null"。
尝试添加一个明确的非 "null" 默认值。

我的代码如下:

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

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!),
  ),
),

答案1

得分: 1

提到参数chatmessage,类型为ChatMessage?

您的代码应该像这样..

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

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!),
  ),
),

huangapple
  • 本文由 发表于 2023年2月18日 15:29:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491843.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定