【发布时间】:2021-02-07 04:44:03
【问题描述】:
当我尝试存储 DocumentReference 类型时,出现以下错误
未处理的异常:将对象转换为可编码对象失败:“DocumentReference”实例
我在想解析错误,但我不知道确切
【问题讨论】:
-
请分享您遇到异常的几段代码和完整的堆栈跟踪
-
JSON OBJECT ------> {subTotal: 14999.0, grandTotal: 14999.0, deliveryCharge: 0.0, deliveryLocation: null, products: [{quantity: 1, productRef: DocumentReference(products/5RVVNBMXxiYqJ0lTrfYX) }], userRef: DocumentReference(users/2rdRXf2on6h0B3igNvwn0IIOWox1), createdAt: 2020-10-24 21:15:25.083351, paymentType: null, tax: 0.0} 存储到sharedPreference方法------------> static Future
setCartInfo(Map cartInfo) async { SharedPreferences prefs = await SharedPreferences.getInstance();返回 prefs.setString('cartInfo', jsonEncode(cartInfo)); } -
下面是错误 Unhandled Exception: Converting object to an encodable object failed: Instance of 'DocumentReference'