enum SourceOpenTarget { Local, FullContent, Webpage, External, Inherit } SourceOpenTarget resolveOpenTargetCascade( SourceOpenTarget sourceTarget, SourceOpenTarget groupTarget, SourceOpenTarget globalTarget, ) { if (sourceTarget != SourceOpenTarget.Inherit) return sourceTarget; if (groupTarget != SourceOpenTarget.Inherit) return groupTarget; return globalTarget; } class RSSSource { String id; String url; String? iconUrl; String name; SourceOpenTarget openTarget; int unreadCount; DateTime latest; String lastTitle; RSSSource(this.id, this.url, this.name) : openTarget = SourceOpenTarget.Inherit, latest = DateTime.now(), unreadCount = 0, lastTitle = ""; RSSSource._privateConstructor( this.id, this.url, this.iconUrl, this.name, this.openTarget, this.unreadCount, this.latest, this.lastTitle, ); RSSSource clone() { return RSSSource._privateConstructor( this.id, this.url, this.iconUrl, this.name, this.openTarget, this.unreadCount, this.latest, this.lastTitle, ); } Map toMap() { return { "sid": id, "url": url, "iconUrl": iconUrl, "name": name, "openTarget": openTarget.index, "latest": latest.millisecondsSinceEpoch, "lastTitle": lastTitle, }; } RSSSource.fromMap(Map map) : id = map["sid"], url = map["url"], iconUrl = map["iconUrl"], name = map["name"], openTarget = (map["openTarget"] as int) < SourceOpenTarget.values.length ? SourceOpenTarget.values[map["openTarget"]] : SourceOpenTarget.Local, latest = DateTime.fromMillisecondsSinceEpoch(map["latest"]), lastTitle = map["lastTitle"], unreadCount = 0; }