[英]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
.在这里,如果值包含不能直接encodable
为JSON
字符串的objects
(不是number
、 boolean
、 string
、 null
、 list
或带有字符串keys
的map
的值), toEncodable
function 用于将其转换为那必须是直接encodable
的。
const data = {};
final String jsonString = jsonEncode(data);
print(jsonString);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.