繁体   English   中英

我在 flutter 中收到错误“未处理的异常:将 object 转换为可编码的 object 失败:Null”

[英]I get the error 'Unhandled Exception: Converting object to an encodable object failed: Null' in flutter

我正在尝试将 JSON 发布到我们的 api,但即使所有值都是 NULL 并且允许为 NULL,也会继续收到此错误,这是导致问题的代码片段。

   final response = await http.post(Uri.parse('http://"api"/api/createPin'),
    body: json.encode({

      'location': Null,
      'description': Null,
      'qrcode': Null,
      'ttl': Null,
      'tier': Null,
      'type': Null,
      'user': Null,
      'images': Null,
      'viewable_users': Null
    }),
    );

我搜索了论坛和一些视频,但都没有解决我的问题,我不知道我做错了什么。

Null更改为null怎么样?

您正在寻找“空”而不是“空”。

Null 是一个无法实例化的 class 和 null 一个值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM