Line data Source code
1 : import 'package:equatable/equatable.dart';
2 : import 'package:json_annotation/json_annotation.dart';
3 :
4 : part 'group.g.dart';
5 :
6 : ///
7 : @JsonSerializable(createToJson: true, genericArgumentFactories: true)
8 : class Group<T> extends Equatable {
9 : ///
10 3 : const Group({
11 : this.id,
12 : this.group,
13 : this.activities,
14 : this.actorCount,
15 : this.createdAt,
16 : this.updatedAt,
17 : });
18 :
19 : /// Create a new instance from a json
20 2 : factory Group.fromJson(
21 : Map<String, dynamic> json,
22 : T Function(Object?) fromJsonT,
23 : ) =>
24 2 : _$GroupFromJson(json, fromJsonT);
25 :
26 : ///
27 : final String? id;
28 :
29 : ///
30 : final String? group;
31 :
32 : ///
33 : final List<T>? activities;
34 :
35 : ///
36 : final int? actorCount;
37 :
38 : ///
39 : final DateTime? createdAt;
40 :
41 : ///
42 : final DateTime? updatedAt;
43 :
44 3 : @override
45 3 : List<Object?> get props => [
46 3 : id,
47 3 : group,
48 3 : activities,
49 3 : actorCount,
50 3 : createdAt,
51 3 : updatedAt,
52 : ];
53 :
54 : /// Serialize to json
55 1 : Map<String, dynamic> toJson(Object Function(T) toJsonT) =>
56 1 : _$GroupToJson(this, toJsonT);
57 : }
58 :
59 : ///
60 : @JsonSerializable(createToJson: true, genericArgumentFactories: true)
61 : class NotificationGroup<T> extends Group<T> {
62 : ///
63 2 : const NotificationGroup({
64 : String? id,
65 : String? group,
66 : List<T>? activities,
67 : int? actorCount,
68 : DateTime? createdAt,
69 : DateTime? updatedAt,
70 : this.isRead,
71 : this.isSeen,
72 2 : }) : super(
73 : id: id,
74 : group: group,
75 : activities: activities,
76 : actorCount: actorCount,
77 : createdAt: createdAt,
78 : updatedAt: updatedAt,
79 : );
80 :
81 : /// Create a new instance from a json
82 2 : factory NotificationGroup.fromJson(
83 : Map<String, dynamic> json,
84 : T Function(Object? json) fromJsonT,
85 : ) =>
86 2 : _$NotificationGroupFromJson(json, fromJsonT);
87 :
88 : ///
89 : final bool? isRead;
90 :
91 : ///
92 : final bool? isSeen;
93 :
94 2 : @override
95 2 : List<Object?> get props => [
96 2 : ...super.props,
97 2 : isRead,
98 2 : isSeen,
99 : ];
100 :
101 : /// Serialize to json
102 1 : @override
103 : Map<String, dynamic> toJson(Object Function(T) toJsonT) =>
104 1 : _$NotificationGroupToJson(this, toJsonT);
105 : }
|