0

我在颤振/飞镖上使用 ObjectBox (3.0.0) 来实现数据库部分。在一个实体中,我希望添加一个枚举类型列表。

enum ExampleEnum {
    exampleOne,
    exampleTwo,
    ...
}


@Entity()
class Examples {
  /// ObjectBox 64-bit integer ID property, mandatory.
  int id = 0;

  /// List of Examples.
  List<ExampleEnum> examples = [];
}

我收到此警告:

[WARNING] objectbox_generator:resolver on lib/entity/examples.dart:
  skipping property 'examples' in entity 'Examples', as it has an unsupported type: 'List<ExampleEnum>'

如果我尝试通过 List 仅将枚举索引存储在 ExampleEnum 类型中,我会收到此错误:

[WARNING] objectbox_generator:resolver on lib/entity/examples.dart:
  skipping property 'examples' in entity 'Examples', as it has an unsupported type: 'List<int>'

如何在我的 Entity 中正确存储枚举类型列表?

4

1 回答 1

0

此时(2022 年 1 月),不直接支持枚举值列表。一种解决方法是允许自定义类型的类型转换器。

于 2022-01-21T10:52:38.740 回答