Skip to content

Support freezed entities #229

Closed
Closed
@msxenon

Description

@msxenon

Hello,
as far as I know in objectbox-dart we can't create an immutable class.

I have used @freezed with "HiveDB" but I wish we can achieve that with object box

Example:

part 'priority_entity.freezed.dart';
part 'priority_entity.g.dart';

@freezed
abstract class PriorityEntity with _$PriorityEntity {
  @HiveType(typeId: 2, adapterName: 'PriorityEntityAdapter')
  const factory PriorityEntity({
    @required @HiveField(0) String id,
    @required @HiveField(1) @JsonKey(name: 'org_id') String orgId,
    @required @HiveField(2) String name,
    @required @HiveField(3) bool active,
    @required @HiveField(4) List<PriorityStates> states,
  }) = _PriorityEntity;

  factory PriorityEntity.fromJson(Map<String, dynamic> json) =>
      _$PriorityEntityFromJson(json);
}

edit by @vaind: fix the code block

Metadata

Metadata

Assignees

No one assigned

    Labels

    doneThis issue already has a pull request that is likely to close this issue after it's merged.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions