简体   繁体   English

未处理的异常:将 object 转换为可编码的 object 失败:“TextEditingController”实例

[英]Unhandled Exception: Converting object to an encodable object failed: Instance of 'TextEditingController'

I got this error when I tried to send data to an API endpoint in Flutter. I don't seem to understand where the error is coming from.当我尝试将数据发送到 Flutter 中的 API 端点时出现此错误。我似乎不明白错误来自何处。

Here is my data:这是我的数据:

     var data = {
      'first_name': widget.first_name.toString(),
      'last_name': widget.last_name.toString(),
      'username': username.text,
      'email': widget.email.toString(),
      'mobile_number': widget.mobile_number.toString(),
      'password': password.text,
      'gender': gender,
      'repeat_password': repeat_password.text,
      'dob': dob,
      'accepted_terms': 'on'
    };

Here, If value contains objects that are not directly encodable to a JSON string (a value that is not a number , boolean , string , null , list or a map with string keys ), the toEncodable function is used to convert it to an object that must be directly encodable .在这里,如果值包含不能直接encodableJSON字符串的objects (不是numberbooleanstringnulllist或带有字符串keysmap的值), toEncodable function 用于将其转换为那必须是直接encodable的。

const data = {};
final String jsonString = jsonEncode(data);
print(jsonString);

暂无
暂无

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

相关问题 Flutter:未处理的异常:将对象转换为可编码对象失败:“AddProjectModel”的实例 - Flutter: Unhandled Exception: Converting object to an encodable object failed: Instance of 'AddProjectModel' 未处理的异常:将 object 转换为可编码的 object 失败:“测量”实例 - Unhandled Exception: Converting object to an encodable object failed: Instance of 'Mesure' 未处理的异常:将对象转换为可编码对象失败:“产品”实例 - Unhandled Exception: Converting object to an encodable object failed: Instance of 'Product' 未处理的异常:将 object 转换为可编码的 object 失败:“LoginModel”实例 - Unhandled Exception: Converting object to an encodable object failed: Instance of 'LoginModel' 未处理的异常:将 object 转换为可编码的 object 失败:“日期时间”实例 - Unhandled Exception: Converting object to an encodable object failed: Instance of 'DateTime' 未处理的异常:将 object 转换为可编码的 object 失败:“XFile”实例 - Unhandled Exception: Converting object to an encodable object failed: Instance of 'XFile' 如何解决未处理的异常:将对象转换为可编码对象失败? - how to solve Unhandled Exception: Converting object to an encodable object failed? 未处理的异常:将对象转换为可编码对象失败:摄影 - Unhandled Exception: Converting object to an encodable object failed: Photography 未处理的异常:将 object 转换为可编码的 object 失败:_LinkedHashMap - Unhandled Exception: Converting object to an encodable object failed: _LinkedHashMap 未处理的异常:DioError [DioErrorType.DEFAULT]:将对象转换为可编码的 object 失败:“DateTime”实例 - Unhandled Exception: DioError [DioErrorType.DEFAULT]: Converting objects to an encodable object failed: Instance of 'DateTime'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM