繁体   English   中英

如何在 Flutter/Datrt ObjectBox 中存储枚举数据列表?

[英]How store list of enumeration data in Flutter/Datrt ObjectBox?

我在颤振/飞镖上使用 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>'

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM