import "package:equatable/equatable.dart"; import "package:photos/models/api/entity/type.dart"; class LocalEntityData { final String id; final EntityType type; final String data; final int ownerID; final int updatedAt; LocalEntityData({ required this.id, required this.type, required this.data, required this.ownerID, required this.updatedAt, }); Map toJson() { return { "id": id, "type": type.typeToString(), "data": data, "ownerID": ownerID, "updatedAt": updatedAt, }; } factory LocalEntityData.fromJson(Map json) { return LocalEntityData( id: json["id"], type: typeFromString(json["type"]), data: json["data"], ownerID: json["ownerID"] as int, updatedAt: json["updatedAt"] as int, ); } } class LocalEntity extends Equatable { final T item; final String id; const LocalEntity(this.item, this.id); @override List get props => [item, id]; }