繁体   English   中英

错误:将 object 转换为可编码的 object 失败

[英]Error: Converting object to an encodable object failed

错误:

Произошло исключение.
JsonUnsupportedObjectError (Converting object to an encodable object failed: Closure: () => Map<dynamic, dynamic>)

代码:

Map toJson() => {
                "UnigTime": {
                  "hour": _timerHourCurrentSliderValue,
                  "minute": _timerMinuteCurrentSliderValue.toInt()
                }
              };
          final jsonAllTime = jsonEncode(toJson);
          Server().async(jsonAllTime);

您正在尝试转换Function 而不是这条线

          final jsonAllTime = jsonEncode(toJson);

你应该有这一行,它返回Map

          final jsonAllTime = jsonEncode(toJson());

暂无
暂无

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

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