flutter SDK pics文件类型 关联文件错误

void _uploadImage() async{
EasyLoading.show(status: "正在上传图片");
LCFile file = await LCFile.fromPath('oldgoods', _oldGoodsImageFilePath);
file.save().then((value) {
EasyLoading.dismiss();
_submitForm(file);
}).catchError((error) {
EasyLoading.showToast("上传文件失败");
});
}

void _submitForm(LCFile file){

String goodName = _goodsNameController.text;
String goodDes = _goodsDesController.text;

DeviceInfoPlugin().androidInfo.then((onValue){

  LCObject object = new LCObject("oldGoods");
  object["name"] = goodName; // String
  object["des"] = goodDes; // String
  object["uid"] = onValue.androidId; //String
  object.add("pics", file);

请把错误信息粘贴一下

void _submitForm(LCFile file){
LCObject object = new LCObject("oldGoods");
object["name"] = goodName; // String
object["des"] = goodDes; // String
object["uid"] = onValue.androidId; //String
object.add("attachments", file);

  object.save().then((object) {
    //返回到列表页
    _goodsNameController.text = "";
    _goodsDesController.text = "";
    Navigator.pop(context);

  }).catchError((error) {
    print("----->" + error.toString());
  });

}

错误信息:----->Instance of 'LCException'

没看出来有价值的错误信息,而且我是图片上传成功了的,就是object.add("attachments", file) 的时候发生了错误,然后我看了表数据除了attachments没有保存,其它字段是保存成功了

LCException 是 SDK 定义的异常类型,可以看下具体的 code 和 message

另外,之前 SDK 可能在 Object 关联 File 时,保存时有 bug。所以请确认 SDK 是最新版本 0.4.1
我这边模拟你那边测试了一下是正常的

      LCFile file = await LCFile.fromPath('avatar', './avatar.jpg');
      LCObject obj = new LCObject('FileObject');
      obj['file'] = file;
      String text = 'hello, world';
      Uint8List data = utf8.encode(text);
      LCFile file2 = LCFile.fromBytes('text', data);
      obj.add('files', file);
      obj.add('files', file2);
      // obj['files'] = [file, file2];
      await obj.save();
      assert(file.objectId != null && file.url != null);
      assert(file2.objectId != null && file2.url != null);
      assert(obj.objectId != null);

好的,多谢,我用的是0.3.9版本,我更新一下

现在上传成功,官方文档没有说明如何显示图片及获取图片url

LCFile 是子类化的 LCObject,上传成功后,可以通过 LCFile.url 获取图片。
至于如何显示,可能要看具体的显示组件使用方式。

上传完成图片url我知道嘞,我现在要获取商品列表,如何获取url?

参考一下 文档
include 方法即可拉取 LCFile 对象的完整数据。