-
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathyoutube_subscription.dart
49 lines (43 loc) · 1.44 KB
/
youtube_subscription.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class YoutubeSubscription {
final String title;
final String channelID;
final bool? subscribed;
final List<String> groups;
DateTime? lastFetched;
YoutubeSubscription({
String? title,
required this.channelID,
required this.subscribed,
this.groups = const [],
this.lastFetched,
}) : title = title ?? '';
factory YoutubeSubscription.fromJson(Map<String, dynamic> json) {
return YoutubeSubscription(
title: json['title'] ?? '',
channelID: json['channelID'] ?? '',
subscribed: json['subscribed'],
groups: (json['groups'] as List?)?.cast<String>() ?? [],
lastFetched: DateTime.fromMillisecondsSinceEpoch(json['lastFetched'] ?? 0),
);
}
Map<String, dynamic> toJson() {
return {
"title": title,
"channelID": channelID,
"subscribed": subscribed,
"groups": groups,
"lastFetched": lastFetched?.millisecondsSinceEpoch,
};
}
@override
bool operator ==(covariant YoutubeSubscription other) {
if (identical(this, other)) return true;
return other.title == title && other.channelID == channelID && other.subscribed == subscribed && other.lastFetched == lastFetched;
}
@override
int get hashCode {
return title.hashCode ^ channelID.hashCode ^ subscribed.hashCode ^ lastFetched.hashCode;
}
@override
String toString() => "YoutubeSubscription(title: $title, channelID: $channelID, subscribed: $subscribed, lastFetched: $lastFetched)";
}