是否需要在 Hive 中注册对象列表?

问题描述

这是我的 Hive 模型,我已经生成了适配器:

@HiveType(typeId: 7)
class GoalModel {
  @HiveField(0)
  bool progessNotificaitons;
  @HiveField(1)
  List<DayModel> daysToWork;
  @HiveField(2)
  int amountGoal;
  @HiveField(3)
  DateTime initialDate;
  GoalModel({
    this.amountGoal,this.daysToWork,this.initialDate,this.progessNotificaitons,});
}

class DayModel {
  String label;
  int index;
  bool gonnaWork;
  DayModel({
    this.gonnaWork,this.index,this.label,});
}

问题是不允许我保存 daysToWork,它是没有适配器的类 DayModel 的列表。问题是:是否需要生成适配器或任何特殊配置来保存某种类型的对象列表?

提前致谢。

解决方法

响应为 YES,即使您只是要将对象发布到另一个对象的列表中,也需要生成一个注册新适配器。