'Error: Converting object to an encodable object failed
Error:
Произошло исключение.
JsonUnsupportedObjectError (Converting object to an encodable object failed: Closure: () => Map<dynamic, dynamic>)
Code:
Map toJson() => {
"UnigTime": {
"hour": _timerHourCurrentSliderValue,
"minute": _timerMinuteCurrentSliderValue.toInt()
}
};
final jsonAllTime = jsonEncode(toJson);
Server().async(jsonAllTime);
Solution 1:[1]
You are trying to convert a Function. instead of this line
final jsonAllTime = jsonEncode(toJson);
you should have this line where it returns the Map
final jsonAllTime = jsonEncode(toJson());
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Majid |
