如何在Flutter Dio软件包中添加地图
我想使用DIO软件包将表单数据发送到后端,其中一个字段接受地图而不是字符串。
formData.fields.add(MapEntry('category', _category));
formData.fields.add(MapEntry('license_number', _licenseNumber.text));
formData.fields.add(MapEntry('license_issued_on', _licenseIssueDateString));
//The line below is the one causing the error. The argument type 'Map<String, Object>' can't be assigned to the parameter type 'String'.
formData.fields.add(MapEntry('address', {'address': _address.text, 'lattitude': _addressLat, 'longitude': _addressLng}));
FormData接口提供了一种方法,可以轻松构造一组键/值对,代表表单字段及其值 我该如何解决这个问题?
I want to send a form data to the backend using the Dio package one of the fields accepts a map instead of a String.
formData.fields.add(MapEntry('category', _category));
formData.fields.add(MapEntry('license_number', _licenseNumber.text));
formData.fields.add(MapEntry('license_issued_on', _licenseIssueDateString));
//The line below is the one causing the error. The argument type 'Map<String, Object>' can't be assigned to the parameter type 'String'.
formData.fields.add(MapEntry('address', {'address': _address.text, 'lattitude': _addressLat, 'longitude': _addressLng}));
The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values
How can I go around this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将地图转换为JSON字符串。自然的后端必须解码一个字符串。
Convert a map to a JSON string. Naturally backend has to decode a string.