Error: Converting object to an encodable object failed
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);
你应该在 returns Map
这行
final jsonAllTime = jsonEncode(toJson());
错误:
Произошло исключение.
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);
你应该在 returns Map
final jsonAllTime = jsonEncode(toJson());