sqlite 列表< >不支持列类型

kg7wmglp  于 6个月前  发布在  SQLite
关注(0)|答案(1)|浏览(70)

我在flutter应用程序中使用floor作为SQLite抽象。
我想用礼物列表保存一个人,所以我创建了一个ForeignKey(如前面提到的here),并将子idMap到父presents,但是当我通过flutter packages pub run build_runner build运行生成器时,我得到了错误Column type is not supported for List<Present>
我把现在和人作为实体。

@entity
class Present {
  @PrimaryKey(autoGenerate: true)
  int? id;
  String name;
  double? price;

  Present({this.id, required this.name, this.price});
}

个字符

gojuced7

gojuced71#

我认为在floor中,你不能使用复杂类型作为属性来建模关系。看看https://github.com/pinchbv/floor/blob/develop/docs/entities.md ......这里只引用了普通的外键。仍然有一个打开的@Relation注解功能请求打开,但据我所知,它没有实现。相反,你可能必须自己加载和Map关系。

相关问题