简体   繁体   中英

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);

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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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