fix freezed definitions

This commit is contained in:
Henry Hiles 2026-08-22 12:43:42 -04:00
commit 78744135c9
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
51 changed files with 540 additions and 320 deletions

View file

@ -2,6 +2,7 @@ analyzer:
errors:
invalid_annotation_target: ignore
avoid_print: ignore
annotate_overrides: ignore
exclude:
- "build/**"
- "**/*.g.dart"

View file

@ -5,20 +5,21 @@ part "account_data.freezed.dart";
part "account_data.g.dart";
@freezed
sealed class const AccountData({
@JsonSerializable()
class const AccountData({
@JsonKey(name: AccountData.invitePermissionConfigKey)
InvitePermissionConfig invitePermissionConfig =
final InvitePermissionConfig invitePermissionConfig =
const _InvitePermissionConfig(),
@JsonKey(name: AccountData.directKey)
IMap<String, IList<String>> directMessages = const IMap.empty(),
final IMap<String, IList<String>> directMessages = const IMap.empty(),
@JsonKey(
name: AccountData.recentEmojiKey,
readValue: AccountData.readRecentEmojiValue,
toJson: AccountData.recentEmojiToJson,
)
IList<RecentEmoji> recentEmoji = const IList.empty(),
final IList<RecentEmoji> recentEmoji = const IList.empty(),
}) with _$AccountData {
static List<dynamic>? readRecentEmojiValue(
Map<dynamic, dynamic> json,
@ -33,22 +34,33 @@ sealed class const AccountData({
static const directKey = "m.direct";
static const recentEmojiKey = "m.recent_emoji";
@override
Map<String, Object?> toJson() => _$AccountDataToJson(this);
factory AccountData.fromJson(Map<String, Object?> json) =>
_$AccountDataFromJson(json);
}
@freezed
sealed class const InvitePermissionConfig({
@JsonSerializable()
class const InvitePermissionConfig({
@JsonKey(unknownEnumValue: DefaultInviteAction.allow)
DefaultInviteAction defaultAction = DefaultInviteAction.allow,
final DefaultInviteAction defaultAction = DefaultInviteAction.allow,
}) with _$InvitePermissionConfig {
@override
Map<String, Object?> toJson() => _$InvitePermissionConfigToJson(this);
factory InvitePermissionConfig.fromJson(Map<String, Object?> json) =>
_$InvitePermissionConfigFromJson(json);
}
@freezed
sealed class const RecentEmoji({required String emoji, required int total})
@JsonSerializable()
class const RecentEmoji({required final String emoji, required final int total})
with _$RecentEmoji {
@override
Map<String, Object?> toJson() => _$RecentEmojiToJson(this);
factory RecentEmoji.fromJson(Map<String, Object?> json) =>
_$RecentEmojiFromJson(json);
}

View file

@ -4,13 +4,17 @@ part "client_state.freezed.dart";
part "client_state.g.dart";
@freezed
sealed class const ClientState({
required bool isInitialized,
required bool isLoggedIn,
required bool isVerified,
required String? userId,
required String? homeserverUrl,
@JsonSerializable()
class const ClientState({
required final bool isInitialized,
required final bool isLoggedIn,
required final bool isVerified,
required final String? userId,
required final String? homeserverUrl,
}) with _$ClientState {
@override
Map<String, Object?> toJson() => _$ClientStateToJson(this);
factory ClientState.fromJson(Map<String, Object?> json) =>
_$ClientStateFromJson(json);
}

View file

@ -5,10 +5,14 @@ part "members_by_status.freezed.dart";
part "members_by_status.g.dart";
@freezed
sealed class const MembersByStatusConfig({
required String roomId,
required MembershipStatus status,
@JsonSerializable()
class const MembersByStatusConfig({
required final String roomId,
required final MembershipStatus status,
}) with _$MembersByStatusConfig {
@override
Map<String, Object?> toJson() => _$MembersByStatusConfigToJson(this);
factory MembersByStatusConfig.fromJson(Map<String, Object?> json) =>
_$MembersByStatusConfigFromJson(json);
}

View file

@ -4,10 +4,14 @@ part "reactions.freezed.dart";
part "reactions.g.dart";
@freezed
sealed class const ReactionsConfig({
required String roomId,
required int eventRowId,
@JsonSerializable()
class const ReactionsConfig({
required final String roomId,
required final int eventRowId,
}) with _$ReactionsConfig {
@override
Map<String, Object?> toJson() => _$ReactionsConfigToJson(this);
factory ReactionsConfig.fromJson(Map<String, Object?> json) =>
_$ReactionsConfigFromJson(json);
}

View file

@ -4,8 +4,12 @@ part "user.freezed.dart";
part "user.g.dart";
@freezed
sealed class const UserConfig({String? roomId, required String userId})
@JsonSerializable()
class const UserConfig({final String? roomId, required final String userId})
with _$UserConfig {
@override
Map<String, Object?> toJson() => _$UserConfigToJson(this);
factory UserConfig.fromJson(Map<String, Object?> json) =>
_$UserConfigFromJson(json);
}

View file

@ -31,7 +31,11 @@ enum RoomType {
}
@freezed
sealed class const PreviousRoom({required String roomId}) with _$PreviousRoom {
@JsonSerializable()
class const PreviousRoom({required final String roomId}) with _$PreviousRoom {
@override
Map<String, Object?> toJson() => _$PreviousRoomToJson(this);
factory PreviousRoom.fromJson(Map<String, Object?> json) =>
_$PreviousRoomFromJson(json);
}

View file

@ -18,10 +18,14 @@ sealed class JoinRulesContent extends Content with _$JoinRulesContent {
}
@freezed
sealed class const AllowCondition({
String? roomId,
required AllowConditionType type,
@JsonSerializable()
class const AllowCondition({
final String? roomId,
required final AllowConditionType type,
}) with _$AllowCondition {
@override
Map<String, Object?> toJson() => _$AllowConditionToJson(this);
factory AllowCondition.fromJson(Map<String, Object?> json) =>
_$AllowConditionFromJson(json);
}

View file

@ -25,10 +25,14 @@ sealed class PowerLevelsContent extends Content with _$PowerLevelsContent {
}
@freezed
sealed class const Notifications({
int room = 50,
IMap<String, int> other = const IMap.empty(),
@JsonSerializable()
class const Notifications({
final int room = 50,
final IMap<String, int> other = const IMap.empty(),
}) with _$Notifications {
@override
Map<String, Object?> toJson() => _$NotificationsToJson(this);
factory Notifications.fromJson(Map<String, Object?> json) =>
_$NotificationsFromJson(json);
}

View file

@ -18,18 +18,26 @@ sealed class TopicContent extends Content with _$TopicContent {
}
@freezed
sealed class const TopicContentBlock({
IList<TextualRepresentation> representations = const IList.empty(),
@JsonSerializable()
class const TopicContentBlock({
final IList<TextualRepresentation> representations = const IList.empty(),
}) with _$TopicContentBlock {
@override
Map<String, Object?> toJson() => _$TopicContentBlockToJson(this);
factory TopicContentBlock.fromJson(Map<String, Object?> json) =>
_$TopicContentBlockFromJson(json);
}
@freezed
sealed class const TextualRepresentation({
required String body,
String mimetype = "text/plain",
@JsonSerializable()
class const TextualRepresentation({
required final String body,
final String mimetype = "text/plain",
}) with _$TextualRepresentation {
@override
Map<String, Object?> toJson() => _$TextualRepresentationToJson(this);
factory TextualRepresentation.fromJson(Map<String, Object?> json) =>
_$TextualRepresentationFromJson(json);
}

View file

@ -8,31 +8,35 @@ part "event.freezed.dart";
part "event.g.dart";
@freezed
sealed class const Event({
@JsonKey(name: "rowid") required int rowId,
@JsonKey(name: "timeline_rowid") required int timelineRowId,
required String roomId,
required String eventId,
required String sender,
@JsonKey(readValue: Event.typeJsonFromJson) required String type,
String? stateKey,
@EpochDateTimeConverter() required DateTime timestamp,
IMap<String, dynamic> unsigned = const IMap.empty(),
LocalContent? localContent,
String? transactionId,
String? redactedBy,
String? relatesTo,
String? relationType,
String? replyTo,
String? decryptionError,
String? sendError,
IMap<String, int> reactions = const IMap.empty(),
@JsonKey(name: "last_edit_rowid") int lastEditRowId = 0,
@UnreadTypeConverter() UnreadType? unreadType,
Profile? pmp,
required Content content,
required Content? previousContent,
@JsonSerializable()
class const Event({
@JsonKey(name: "rowid") required final int rowId,
@JsonKey(name: "timeline_rowid") required final int timelineRowId,
final String? stateKey,
required final String roomId,
required final String eventId,
required final String sender,
@JsonKey(readValue: Event.typeJsonFromJson) required final String type,
@EpochDateTimeConverter() @override required final DateTime timestamp,
final IMap<String, dynamic> unsigned = const IMap.empty(),
final LocalContent? localContent,
final String? transactionId,
final String? redactedBy,
final String? relatesTo,
final String? relationType,
final String? replyTo,
final String? decryptionError,
final String? sendError,
final IMap<String, int> reactions = const IMap.empty(),
@JsonKey(name: "last_edit_rowid") @override final int lastEditRowId = 0,
@UnreadTypeConverter() @override final UnreadType? unreadType,
final Profile? pmp,
required final Content content,
required final Content? previousContent,
}) with _$Event {
@override
Map<String, Object?> toJson() => _$EventToJson(this);
static String typeJsonFromJson(Map<dynamic, dynamic> json, _) =>
json["decrypted_type"] ?? json["type"];
@ -72,14 +76,19 @@ sealed class const Event({
}
@freezed
sealed class const LocalContent({
String? sanitizedHtml,
String? editSource,
bool? wasPlaintext,
bool? bigEmoji,
bool? hasMath,
bool? replyFallbackRemoved,
@JsonSerializable()
class const LocalContent({
final String? sanitizedHtml,
final String? editSource,
final bool? wasPlaintext,
final bool? bigEmoji,
final bool? hasMath,
final bool? replyFallbackRemoved,
}) with _$LocalContent {
@override
Map<String, Object?> toJson() => _$LocalContentToJson(this);
@override
factory LocalContent.fromJson(Map<String, Object?> json) =>
_$LocalContentFromJson(json);
}

View file

@ -3,9 +3,9 @@ import "package:freezed_annotation/freezed_annotation.dart";
part "homeserver.freezed.dart";
@freezed
sealed class const Homeserver({
required String name,
required String description,
required Uri url,
required String iconUrl,
class const Homeserver({
@override required final String name,
@override required final String description,
@override required final Uri url,
@override required final String iconUrl,
}) with _$Homeserver;

View file

@ -5,11 +5,15 @@ part "audio.freezed.dart";
part "audio.g.dart";
@freezed
sealed class const AudioInfo({
@MSDuration() Duration? duration,
@JsonKey(name: "mimetype") String? mimeType,
int? size,
@JsonSerializable()
class const AudioInfo({
@MSDuration() final Duration? duration,
@JsonKey(name: "mimetype") final String? mimeType,
final int? size,
}) with _$AudioInfo {
@override
Map<String, Object?> toJson() => _$AudioInfoToJson(this);
factory AudioInfo.fromJson(Map<String, Object?> json) =>
_$AudioInfoFromJson(json);
}

View file

@ -4,10 +4,14 @@ part "file.freezed.dart";
part "file.g.dart";
@freezed
sealed class const FileInfo({
@JsonKey(name: "mimetype") String? mimeType,
int? size,
@JsonSerializable()
class const FileInfo({
@JsonKey(name: "mimetype") final String? mimeType,
final int? size,
}) with _$FileInfo {
@override
Map<String, Object?> toJson() => _$FileInfoToJson(this);
factory FileInfo.fromJson(Map<String, Object?> json) =>
_$FileInfoFromJson(json);
}

View file

@ -4,13 +4,17 @@ part "image.freezed.dart";
part "image.g.dart";
@freezed
sealed class const ImageInfo({
@JsonKey(name: "h") double? height,
@JsonKey(name: "w") double? width,
@JsonKey(name: "mimetype") String? mimeType,
@JsonKey(name: "xyz.amorgan.blurhash") String? blurHash,
int? size,
@JsonSerializable()
class const ImageInfo({
@JsonKey(name: "h") final double? height,
@JsonKey(name: "w") final double? width,
@JsonKey(name: "mimetype") final String? mimeType,
@JsonKey(name: "xyz.amorgan.blurhash") final String? blurHash,
final int? size,
}) with _$ImageInfo {
@override
Map<String, Object?> toJson() => _$ImageInfoToJson(this);
factory ImageInfo.fromJson(Map<String, Object?> json) =>
_$ImageInfoFromJson(json);
}

View file

@ -5,13 +5,17 @@ part "video.freezed.dart";
part "video.g.dart";
@freezed
sealed class const VideoInfo({
@JsonKey(name: "h") int? height,
@JsonKey(name: "w") int? width,
@JsonKey(name: "mimetype") String? mimeType,
@MSDuration() Duration? duration,
int? size,
@JsonSerializable()
class const VideoInfo({
@JsonKey(name: "h") final int? height,
@JsonKey(name: "w") final int? width,
@JsonKey(name: "mimetype") final String? mimeType,
@MSDuration() final Duration? duration,
final int? size,
}) with _$VideoInfo {
@override
Map<String, Object?> toJson() => _$VideoInfoToJson(this);
factory VideoInfo.fromJson(Map<String, Object?> json) =>
_$VideoInfoFromJson(json);
}

View file

@ -5,11 +5,15 @@ part "lazy_load_summary.freezed.dart";
part "lazy_load_summary.g.dart";
@freezed
sealed class const LazyLoadSummary({
required IList<String>? heroes,
required int? joinedMemberCount,
required int? invitedMemberCount,
@JsonSerializable()
class const LazyLoadSummary({
required final IList<String>? heroes,
required final int? joinedMemberCount,
required final int? invitedMemberCount,
}) with _$LazyLoadSummary {
@override
Map<String, Object?> toJson() => _$LazyLoadSummaryToJson(this);
factory LazyLoadSummary.fromJson(Map<String, Object?> json) =>
_$LazyLoadSummaryFromJson(json);
}

View file

@ -4,11 +4,15 @@ part "oauth_auth_code_response.freezed.dart";
part "oauth_auth_code_response.g.dart";
@freezed
sealed class const OAuthAuthCodeResponse({
required String state,
required String codeVerifier,
required Uri url,
@JsonSerializable()
class const OAuthAuthCodeResponse({
required final String state,
required final String codeVerifier,
required final Uri url,
}) with _$OAuthAuthCodeResponse {
@override
Map<String, Object?> toJson() => _$OAuthAuthCodeResponseToJson(this);
factory OAuthAuthCodeResponse.fromJson(Map<String, Object?> json) =>
_$OAuthAuthCodeResponseFromJson(json);
}

View file

@ -4,13 +4,17 @@ part "open_graph_data.freezed.dart";
part "open_graph_data.g.dart";
@freezed
sealed class const OpenGraphData({
@JsonKey(name: "og:title") required String? title,
@JsonKey(name: "og:description") required String? description,
@JsonKey(name: "og:image") required Uri? imageUrl,
@JsonKey(name: "og:image:width") required double? width,
@JsonKey(name: "og:image:height") required double? height,
@JsonSerializable()
class const OpenGraphData({
@JsonKey(name: "og:title") required final String? title,
@JsonKey(name: "og:description") required final String? description,
@JsonKey(name: "og:image") required final Uri? imageUrl,
@JsonKey(name: "og:image:width") required final double? width,
@JsonKey(name: "og:image:height") required final double? height,
}) with _$OpenGraphData {
@override
Map<String, Object?> toJson() => _$OpenGraphDataToJson(this);
factory OpenGraphData.fromJson(Map<String, dynamic> json) =>
_$OpenGraphDataFromJson(json);
}

View file

@ -6,11 +6,15 @@ part "paginate.freezed.dart";
part "paginate.g.dart";
@freezed
sealed class const Paginate({
required IList<Event> events,
required IList<Event> relatedEvents,
required bool hasMore,
@JsonSerializable()
class const Paginate({
required final IList<Event> events,
required final IList<Event> relatedEvents,
required final bool hasMore,
}) with _$Paginate {
@override
Map<String, Object?> toJson() => _$PaginateToJson(this);
factory Paginate.fromJson(Map<String, Object?> json) =>
_$PaginateFromJson(json);
}

View file

@ -6,33 +6,47 @@ part "profile_response.freezed.dart";
part "profile_response.g.dart";
@freezed
sealed class const ProfileResponse({
@JsonKey(fromJson: Profile.fromJson) required Profile profile,
required Bio? bio,
@JsonSerializable()
class const ProfileResponse({
@JsonKey(fromJson: Profile.fromJson) required final Profile profile,
required final Bio? bio,
}) with _$ProfileResponse {
@override
Map<String, Object?> toJson() => _$ProfileResponseToJson(this);
factory ProfileResponse.fromJson(Map<String, Object?> json) =>
_$ProfileResponseFromJson(json);
}
@freezed
sealed class const Bio({required String html, String? editSource}) with _$Bio {
@JsonSerializable()
class const Bio({required final String html, final String? editSource})
with _$Bio {
@override
Map<String, Object?> toJson() => _$BioToJson(this);
factory Bio.fromJson(Map<String, Object?> json) => _$BioFromJson(json);
}
@freezed
sealed class const Profile({
String? id,
String? parseError,
Uri? avatarUrl,
@JsonSerializable()
class const Profile({
final String? id,
final String? parseError,
final Uri? avatarUrl,
@JsonKey(name: "displayname", fromJson: MembershipContent.displaynameFromJson)
String? displayName,
final String? displayName,
@JsonKey(readValue: Profile.readTimezone, name: "m.tz") String? timezone,
@JsonKey(readValue: Profile.readTimezone, name: "m.tz")
final String? timezone,
@JsonKey(readValue: Profile.readPronouns, name: "m.pronouns")
IList<Pronoun> pronouns = const IList.empty(),
final IList<Pronoun> pronouns = const IList.empty(),
}) with _$Profile {
@override
Map<String, Object?> toJson() => _$ProfileToJson(this);
static Object? readPronouns(Map<dynamic, dynamic> map, String key) =>
map[key] ?? map["io.fsky.nyx.pronouns"];
@ -52,8 +66,14 @@ sealed class const Profile({
}
@freezed
sealed class const Pronoun({required String language, required String summary})
with _$Pronoun {
@JsonSerializable()
class const Pronoun({
required final String language,
required final String summary,
}) with _$Pronoun {
@override
Map<String, Object?> toJson() => _$PronounToJson(this);
factory Pronoun.fromJson(Map<String, Object?> json) =>
_$PronounFromJson(json);
}

View file

@ -5,13 +5,17 @@ part "read_receipt.freezed.dart";
part "read_receipt.g.dart";
@freezed
sealed class const ReadReceipt({
String? roomId,
required String userId,
String? threadId,
required String eventId,
@EpochDateTimeConverter() required DateTime timestamp,
@JsonSerializable()
class const ReadReceipt({
final String? roomId,
required final String userId,
final String? threadId,
required final String eventId,
@EpochDateTimeConverter() required final DateTime timestamp,
}) with _$ReadReceipt {
@override
Map<String, Object?> toJson() => _$ReadReceiptToJson(this);
factory ReadReceipt.fromJson(Map<String, Object?> json) =>
_$ReadReceiptFromJson(json);
}

View file

@ -4,12 +4,16 @@ part "download_media.freezed.dart";
part "download_media.g.dart";
@freezed
sealed class const DownloadMediaRequest({
required Uri mxc,
bool encrypted = false,
bool isAvatar = false,
bool thumbnailAvatar = false,
@JsonSerializable()
class const DownloadMediaRequest({
required final Uri mxc,
final bool encrypted = false,
final bool isAvatar = false,
final bool thumbnailAvatar = false,
}) with _$DownloadMediaRequest {
@override
Map<String, Object?> toJson() => _$DownloadMediaRequestToJson(this);
factory DownloadMediaRequest.fromJson(Map<String, Object?> json) =>
_$DownloadMediaRequestFromJson(json);
}

View file

@ -4,11 +4,15 @@ part "get_event.freezed.dart";
part "get_event.g.dart";
@freezed
sealed class const GetEventRequest({
required String roomId,
required String eventId,
bool unredact = false,
@JsonSerializable()
class const GetEventRequest({
required final String roomId,
required final String eventId,
final bool unredact = false,
}) with _$GetEventRequest {
@override
Map<String, Object?> toJson() => _$GetEventRequestToJson(this);
factory GetEventRequest.fromJson(Map<String, Object?> json) =>
_$GetEventRequestFromJson(json);
}

View file

@ -4,11 +4,15 @@ part "get_related_events.freezed.dart";
part "get_related_events.g.dart";
@freezed
sealed class const GetRelatedEventsRequest({
required String roomId,
required String eventId,
required String relationType,
@JsonSerializable()
class const GetRelatedEventsRequest({
required final String roomId,
required final String eventId,
required final String relationType,
}) with _$GetRelatedEventsRequest {
@override
Map<String, Object?> toJson() => _$GetRelatedEventsRequestToJson(this);
factory GetRelatedEventsRequest.fromJson(Map<String, Object?> json) =>
_$GetRelatedEventsRequestFromJson(json);
}

View file

@ -4,12 +4,16 @@ part "get_room_state.freezed.dart";
part "get_room_state.g.dart";
@freezed
sealed class const GetRoomStateRequest({
required String roomId,
bool refetch = false,
bool fetchMembers = false,
bool includeMembers = false,
@JsonSerializable()
class const GetRoomStateRequest({
required final String roomId,
final bool refetch = false,
final bool fetchMembers = false,
final bool includeMembers = false,
}) with _$GetRoomStateRequest {
@override
Map<String, Object?> toJson() => _$GetRoomStateRequestToJson(this);
factory GetRoomStateRequest.fromJson(Map<String, Object?> json) =>
_$GetRoomStateRequestFromJson(json);
}

View file

@ -5,10 +5,14 @@ part "join_room.freezed.dart";
part "join_room.g.dart";
@freezed
sealed class const JoinRoomRequest({
required String roomIdOrAlias,
IList<String> via = const IList.empty(),
@JsonSerializable()
class const JoinRoomRequest({
required final String roomIdOrAlias,
final IList<String> via = const IList.empty(),
}) with _$JoinRoomRequest {
@override
Map<String, Object?> toJson() => _$JoinRoomRequestToJson(this);
factory JoinRoomRequest.fromJson(Map<String, Object?> json) =>
_$JoinRoomRequestFromJson(json);
}

View file

@ -4,13 +4,17 @@ part "exchange_token.freezed.dart";
part "exchange_token.g.dart";
@freezed
sealed class const OAuthExchangeTokenRequest({
required Uri homeserverUrl,
required String codeVerifier,
required Uri redirectUri,
required String code,
required String clientId,
@JsonSerializable()
class const OAuthExchangeTokenRequest({
required final Uri homeserverUrl,
required final String codeVerifier,
required final Uri redirectUri,
required final String code,
required final String clientId,
}) with _$OAuthExchangeTokenRequest {
@override
Map<String, Object?> toJson() => _$OAuthExchangeTokenRequestToJson(this);
factory OAuthExchangeTokenRequest.fromJson(Map<String, Object?> json) =>
_$OAuthExchangeTokenRequestFromJson(json);
}

View file

@ -7,14 +7,18 @@ part "get_auth_url.freezed.dart";
part "get_auth_url.g.dart";
@freezed
sealed class const OAuthGetAuthUrl({
required ResponseMode responseMode,
required Uri homeserverUrl,
required Uri redirectUri,
required IList<String> scopes,
required String clientId,
String? userIdHint,
@JsonSerializable()
class const OAuthGetAuthUrl({
required final ResponseMode responseMode,
required final Uri homeserverUrl,
required final Uri redirectUri,
required final IList<String> scopes,
required final String clientId,
final String? userIdHint,
}) with _$OAuthGetAuthUrl {
@override
Map<String, Object?> toJson() => _$OAuthGetAuthUrlToJson(this);
factory OAuthGetAuthUrl.fromJson(Map<String, Object?> json) =>
_$OAuthGetAuthUrlFromJson(json);
}

View file

@ -5,21 +5,25 @@ part "register_client.freezed.dart";
part "register_client.g.dart";
@freezed
sealed class const OAuthRegisterClientRequest({
required Uri homeserverUrl,
ApplicationType applicationType = ApplicationType.web,
String? clientName,
required Uri clientUri,
Uri? logoUri,
Uri? policyUri,
Uri? tosUri,
IList<GrantType>? grantTypes,
IList<Uri>? redirectUris,
IList<ResponseType>? responseTypes,
@JsonSerializable()
class const OAuthRegisterClientRequest({
required final Uri homeserverUrl,
final ApplicationType applicationType = ApplicationType.web,
final String? clientName,
required final Uri clientUri,
final Uri? logoUri,
final Uri? policyUri,
final Uri? tosUri,
final IList<GrantType>? grantTypes,
final IList<Uri>? redirectUris,
final IList<ResponseType>? responseTypes,
@JsonKey(name: "token_endpoint_auth_method")
AuthMethod? authMethod = AuthMethod.none,
final AuthMethod? authMethod = AuthMethod.none,
}) with _$OAuthRegisterClientRequest {
@override
Map<String, Object?> toJson() => _$OAuthRegisterClientRequestToJson(this);
factory OAuthRegisterClientRequest.fromJson(Map<String, Object?> json) =>
_$OAuthRegisterClientRequestFromJson(json);
}

View file

@ -4,11 +4,15 @@ part "paginate.freezed.dart";
part "paginate.g.dart";
@freezed
sealed class const PaginateRequest({
required String roomId,
required int? maxTimelineId,
int limit = 20,
@JsonSerializable()
class const PaginateRequest({
required final String roomId,
required final int? maxTimelineId,
final int limit = 20,
}) with _$PaginateRequest {
@override
Map<String, Object?> toJson() => _$PaginateRequestToJson(this);
factory PaginateRequest.fromJson(Map<String, Object?> json) =>
_$PaginateRequestFromJson(json);
}

View file

@ -4,11 +4,15 @@ part "report.freezed.dart";
part "report.g.dart";
@freezed
sealed class const ReportRequest({
required String roomId,
required String eventId,
String? reason,
@JsonSerializable()
class const ReportRequest({
required final String roomId,
required final String eventId,
final String? reason,
}) with _$ReportRequest {
@override
Map<String, Object?> toJson() => _$ReportRequestToJson(this);
factory ReportRequest.fromJson(Map<String, Object?> json) =>
_$ReportRequestFromJson(json);
}

View file

@ -5,15 +5,19 @@ part "send_event.freezed.dart";
part "send_event.g.dart";
@freezed
sealed class const SendEventRequest({
required String roomId,
required String type,
required Content content,
String? relatesTo,
String? relationType,
bool synchronous = false,
bool disableEncryption = false,
@JsonSerializable()
class const SendEventRequest({
required final String roomId,
required final String type,
required final Content content,
final String? relatesTo,
final String? relationType,
final bool synchronous = false,
final bool disableEncryption = false,
}) with _$SendEventRequest {
@override
Map<String, Object?> toJson() => _$SendEventRequestToJson(this);
factory SendEventRequest.fromJson(Map<String, Object?> json) =>
_$SendEventRequestFromJson(json);
}

View file

@ -7,30 +7,38 @@ part "send_message.freezed.dart";
part "send_message.g.dart";
@freezed
sealed class const SendMessageRequest({
required String roomId,
required String text,
Content? baseContent,
@JsonKey(name: "mentions") Mentions mentions = const _Mentions(),
@JsonKey(name: "relates_to") Relation? relation,
@JsonSerializable()
class const SendMessageRequest({
required final String roomId,
required final String text,
final Content? baseContent,
@JsonKey(name: "mentions") final Mentions mentions = const _Mentions(),
@JsonKey(name: "relates_to") final Relation? relation,
}) with _$SendMessageRequest {
@override
Map<String, Object?> toJson() => _$SendMessageRequestToJson(this);
factory SendMessageRequest.fromJson(Map<String, Object?> json) =>
_$SendMessageRequestFromJson(json);
}
@freezed
sealed class const Mentions({
bool room = false,
IList<String> userIds = const IList.empty(),
@JsonSerializable()
class const Mentions({
final bool room = false,
final IList<String> userIds = const IList.empty(),
}) with _$Mentions {
@override
Map<String, Object?> toJson() => _$MentionsToJson(this);
factory Mentions.fromJson(Map<String, Object?> json) =>
_$MentionsFromJson(json);
}
@Freezed(toJson: false)
sealed class const Relation({
required String eventId,
required RelationType relationType,
class const Relation({
required final String eventId,
required final RelationType relationType,
}) with _$Relation {
Map<String, dynamic> toJson() {
switch (relationType) {

View file

@ -4,11 +4,15 @@ part "set_account_data.freezed.dart";
part "set_account_data.g.dart";
@freezed
sealed class const SetAccountDataRequest({
required String type,
required dynamic content,
String? roomId,
@JsonSerializable()
class const SetAccountDataRequest({
required final String type,
required final dynamic content,
final String? roomId,
}) with _$SetAccountDataRequest {
@override
Map<String, Object?> toJson() => _$SetAccountDataRequestToJson(this);
factory SetAccountDataRequest.fromJson(Map<String, Object?> json) =>
_$SetAccountDataRequestFromJson(json);
}

View file

@ -5,13 +5,17 @@ part "set_membership.freezed.dart";
part "set_membership.g.dart";
@freezed
sealed class const SetMembershipRequest({
required String userId,
required String roomId,
String? reason,
@JsonKey(name: "action") required MembershipAction action,
@JsonKey(name: "msc4293_redact_events") bool redact = false,
@JsonSerializable()
class const SetMembershipRequest({
required final String userId,
required final String roomId,
final String? reason,
@JsonKey(name: "action") required final MembershipAction action,
@JsonKey(name: "msc4293_redact_events") final bool redact = false,
}) with _$SetMembershipRequest {
@override
Map<String, Object?> toJson() => _$SetMembershipRequestToJson(this);
factory SetMembershipRequest.fromJson(Map<String, Object?> json) =>
_$SetMembershipRequestFromJson(json);
}

View file

@ -6,16 +6,20 @@ part "set_state.freezed.dart";
part "set_state.g.dart";
@freezed
sealed class const SetStateRequest({
required String roomId,
required String type,
required String stateKey,
required Content content,
@JsonSerializable()
class const SetStateRequest({
required final String roomId,
required final String type,
required final String stateKey,
required final Content content,
@JsonKey(name: "delay_ms", includeIfNull: false)
@MSDuration()
Duration? delay,
final Duration? delay,
}) with _$SetStateRequest {
@override
Map<String, Object?> toJson() => _$SetStateRequestToJson(this);
factory SetStateRequest.fromJson(Map<String, Object?> json) =>
_$SetStateRequestFromJson(json);
}

View file

@ -4,20 +4,25 @@ part "upload_media.freezed.dart";
part "upload_media.g.dart";
@freezed
sealed class const UploadMediaRequest({
required String path,
required bool encrypt,
String? filename,
@JsonKey(name: "voice_message") bool isVoiceMessage = false,
bool forceFile = false,
@JsonSerializable()
class const UploadMediaRequest({
required final String path,
required final bool encrypt,
final String? filename,
@JsonKey(name: "voice_message") final bool isVoiceMessage = false,
final bool forceFile = false,
final
// Below params only work if encodeTo is set
String? encodeTo,
int? resizeWidth,
int? resizeHeight,
int? resizePercent,
int quality = 80,
String?
encodeTo,
final int? resizeWidth,
final int? resizeHeight,
final int? resizePercent,
final int quality = 80,
}) with _$UploadMediaRequest {
@override
Map<String, Object?> toJson() => _$UploadMediaRequestToJson(this);
factory UploadMediaRequest.fromJson(Map<String, Object?> json) =>
_$UploadMediaRequestFromJson(json);
}

View file

@ -8,25 +8,26 @@ part "room.freezed.dart";
part "room.g.dart";
@freezed
sealed class const Room({
@JsonKey(name: "meta") RoomMetadata? metadata,
@JsonSerializable()
class const Room({
@JsonKey(name: "meta") final RoomMetadata? metadata,
@JsonKey(fromJson: Room.timelineTupleJsonToIMap)
IMap<int, int?> timeline = const IMap.empty(),
final IMap<int, int?> timeline = const IMap.empty(),
ISet<int> sticky = const ISet.empty(),
final ISet<int> sticky = const ISet.empty(),
@JsonKey(fromJson: Room.eventsJsonToIMap)
IMap<int, Event> events = const IMap.empty(),
final IMap<int, Event> events = const IMap.empty(),
bool reset = false,
bool hasFetchedState = false,
bool hasFetchedMembers = false,
IMap<String, IMap<String, int>> state = const IMap.empty(),
final bool reset = false,
final bool hasFetchedState = false,
final bool hasFetchedMembers = false,
final IMap<String, IMap<String, int>> state = const IMap.empty(),
IMap<String, IList<ReadReceipt>> receipts = const IMap.empty(),
bool dismissNotifications = false,
bool hasMore = true,
final IMap<String, IList<ReadReceipt>> receipts = const IMap.empty(),
final bool dismissNotifications = false,
final bool hasMore = true,
// IMap<String, AccountData> accountData,
// IList<Notification> notifications,
@ -52,5 +53,8 @@ sealed class const Room({
}),
);
@override
Map<String, Object?> toJson() => _$RoomToJson(this);
factory Room.fromJson(Map<String, Object?> json) => _$RoomFromJson(json);
}

View file

@ -6,24 +6,28 @@ part "room_metadata.freezed.dart";
part "room_metadata.g.dart";
@freezed
sealed class const RoomMetadata({
@JsonKey(name: "room_id") required String id,
@JsonSerializable()
class const RoomMetadata({
@JsonKey(name: "room_id") required final String id,
// CreateEventContent creationContent,
// TombstoneEventContent tombstoneEventContent,
String? name,
Uri? avatar,
String? dmUserId,
String? topic,
String? canonicalAlias,
LazyLoadSummary? lazyLoadSummary,
required bool hasMemberList,
@JsonKey(name: "preview_event_rowid") required int previewEventRowID,
@EpochDateTimeConverter() required DateTime sortingTimestamp,
required int unreadHighlights,
required int unreadNotifications,
required int unreadMessages,
final String? name,
final Uri? avatar,
final String? dmUserId,
final String? topic,
final String? canonicalAlias,
final LazyLoadSummary? lazyLoadSummary,
required final bool hasMemberList,
@JsonKey(name: "preview_event_rowid") required final int previewEventRowID,
@EpochDateTimeConverter() required final DateTime sortingTimestamp,
required final int unreadHighlights,
required final int unreadNotifications,
required final int unreadMessages,
}) with _$RoomMetadata {
@override
Map<String, Object?> toJson() => _$RoomMetadataToJson(this);
factory RoomMetadata.fromJson(Map<String, Object?> json) =>
_$RoomMetadataFromJson(json);
}

View file

@ -6,17 +6,21 @@ part "room_summary.freezed.dart";
part "room_summary.g.dart";
@freezed
sealed class const RoomSummary({
required String roomId,
@JsonKey(name: "num_joined_members") required int joinedMembers,
JoinRule? joinRule,
String? name,
Uri? avatarUrl,
String? canonicalAlias,
String? topic,
String? roomVersion,
@JsonKey(unknownEnumValue: RoomType.room) RoomType? roomType,
@JsonSerializable()
class const RoomSummary({
required final String roomId,
@JsonKey(name: "num_joined_members") required final int joinedMembers,
final JoinRule? joinRule,
final String? name,
final Uri? avatarUrl,
final String? canonicalAlias,
final String? topic,
final String? roomVersion,
@JsonKey(unknownEnumValue: RoomType.room) final RoomType? roomType,
}) with _$RoomSummary {
@override
Map<String, Object?> toJson() => _$RoomSummaryToJson(this);
factory RoomSummary.fromJson(Map<String, Object?> json) =>
_$RoomSummaryFromJson(json);
}

View file

@ -5,11 +5,15 @@ part "settings.freezed.dart";
part "settings.g.dart";
@freezed
sealed class const Settings({
ThemeMode theme = ThemeMode.system,
bool useDynamicTheming = true,
bool linuxMobileMode = false,
@JsonSerializable()
class const Settings({
final ThemeMode theme = ThemeMode.system,
final bool useDynamicTheming = true,
final bool linuxMobileMode = false,
}) with _$Settings {
@override
Map<String, Object?> toJson() => _$SettingsToJson(this);
factory Settings.fromJson(Map<String, Object?> json) =>
_$SettingsFromJson(json);
}

View file

@ -6,8 +6,8 @@ import "package:nexus/models/setting.dart";
part "settings_category.freezed.dart";
@freezed
sealed class const SettingsCategory({
required String title,
required IconData icon,
required IList<Setting> settings,
class const SettingsCategory({
required final String title,
required final IconData icon,
required final IList<Setting> settings,
}) with _$SettingsCategory;

View file

@ -7,11 +7,11 @@ import "package:nexus/models/subspace.dart";
part "space.freezed.dart";
@freezed
sealed class const Space({
required String id,
required String title,
IconData? icon,
Room? room,
required IList<Room> children,
required IList<Subspace> subSpaces,
class const Space({
required final String id,
required final String title,
final IconData? icon,
final Room? room,
required final IList<Room> children,
required final IList<Subspace> subSpaces,
}) with _$Space;

View file

@ -4,8 +4,14 @@ part "space_edge.freezed.dart";
part "space_edge.g.dart";
@freezed
sealed class const SpaceEdge({required String childId, bool suggested = false})
with _$SpaceEdge {
@JsonSerializable()
class const SpaceEdge({
required final String childId,
final bool suggested = false,
}) with _$SpaceEdge {
@override
Map<String, Object?> toJson() => _$SpaceEdgeToJson(this);
factory SpaceEdge.fromJson(Map<String, Object?> json) =>
_$SpaceEdgeFromJson(json);
}

View file

@ -5,18 +5,25 @@ part "spec_versions_response.freezed.dart";
part "spec_versions_response.g.dart";
@freezed
sealed class const SpecVersionsResponse({
required IList<String> versions,
required UnstableFeatures unstableFeatures,
@JsonSerializable()
class const SpecVersionsResponse({
required final IList<String> versions,
required final UnstableFeatures unstableFeatures,
}) with _$SpecVersionsResponse {
@override
Map<String, Object?> toJson() => _$SpecVersionsResponseToJson(this);
factory SpecVersionsResponse.fromJson(Map<String, Object?> json) =>
_$SpecVersionsResponseFromJson(json);
}
@freezed
sealed class const UnstableFeatures({
@JsonKey(name: "uk.timedout.msc4494") bool msc4494 = false,
@JsonSerializable()
class const UnstableFeatures({
@JsonKey(name: "uk.timedout.msc4494") final bool msc4494 = false,
}) with _$UnstableFeatures {
Map<String, Object?> toJson() => _$UnstableFeaturesToJson(this);
factory UnstableFeatures.fromJson(Map<String, Object?> json) =>
_$UnstableFeaturesFromJson(json);
}

View file

@ -5,5 +5,7 @@ import "package:nexus/models/room.dart";
part "subspace.freezed.dart";
@freezed
sealed class const Subspace({required Room room, required IList<Room> children})
with _$Subspace;
class const Subspace({
required final Room room,
required final IList<Room> children,
}) with _$Subspace;

View file

@ -7,14 +7,17 @@ part "sync_data.freezed.dart";
part "sync_data.g.dart";
@freezed
sealed class const SyncData({
bool clearState = false,
IMap<String, IMap<String, dynamic>> accountData = const IMap.empty(),
IMap<String, Room> rooms = const IMap.empty(),
ISet<String> leftRooms = const ISet.empty(),
IMap<String, IList<SpaceEdge>>? spaceEdges,
IList<String>? topLevelSpaces,
@JsonSerializable()
class const SyncData({
final bool clearState = false,
final IMap<String, IMap<String, dynamic>> accountData = const IMap.empty(),
final IMap<String, Room> rooms = const IMap.empty(),
final ISet<String> leftRooms = const ISet.empty(),
final IMap<String, IList<SpaceEdge>>? spaceEdges,
final IList<String>? topLevelSpaces,
}) with _$SyncData {
Map<String, Object?> toJson() => _$SyncDataToJson(this);
factory SyncData.fromJson(Map<String, Object?> json) =>
_$SyncDataFromJson(json);
}

View file

@ -4,11 +4,14 @@ part "sync_status.freezed.dart";
part "sync_status.g.dart";
@freezed
sealed class const SyncStatus({
required SyncStatusType type,
required String? error,
required int errorCount,
@JsonSerializable()
class const SyncStatus({
required final SyncStatusType type,
required final String? error,
required final int errorCount,
}) with _$SyncStatus {
Map<String, Object?> toJson() => _$SyncStatusToJson(this);
factory SyncStatus.fromJson(Map<String, Object?> json) =>
_$SyncStatusFromJson(json);
}

View file

@ -77,10 +77,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff
sha256: be169cf6ac481e052c4538715d88841d567150dfe1df38aaec76461a4e7b39f2
url: "https://pub.dev"
source: hosted
version: "4.0.9"
version: "4.1.0"
args:
dependency: transitive
description:
@ -293,10 +293,10 @@ packages:
dependency: transitive
description:
name: dbus
sha256: "792974a4007974fbc5c1b5433eb2330a9db3e368c3f906253af4c007d0f49a91"
sha256: a48d5da28e89bd02196e80d81ed8d7954923d00a0f4a68cc20b575038f023383
url: "https://pub.dev"
source: hosted
version: "0.7.13"
version: "0.7.15"
dynamic_color:
dependency: "direct main"
description:
@ -570,10 +570,10 @@ packages:
dependency: "direct dev"
description:
name: freezed
sha256: "9ec135696554923c59339d46dd50adbaf81099be06ffda0fb9c06f410aea9137"
sha256: "27585a6c2b9ac28ffb7b45d87fd1502332af1eb90e1c9f5eb1acb24c71d26e17"
url: "https://pub.dev"
source: hosted
version: "4.0.0-dev.3"
version: "4.0.0"
freezed_annotation:
dependency: "direct main"
description:
@ -626,10 +626,10 @@ packages:
dependency: "direct main"
description:
name: hooks
sha256: "03a564c3704524ee0f7fc56fc621e8796cc2eb8c24d1f1a33b34979815b285c4"
sha256: eaac480a35ec0814146c2c48d96aaa829e0e44a7662c88ae84c9edf4bc35651f
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.2.0"
hooks_riverpod:
dependency: "direct main"
description:
@ -682,10 +682,10 @@ packages:
dependency: transitive
description:
name: image
sha256: "6300175e00616bbc832e2fc91bfa4d776af5402c81c7151bee6905bb08473c52"
sha256: "1976370a4df3091bb0f72409c187ad1f9132a818bc6b95ca59c0bae1c75c688e"
url: "https://pub.dev"
source: hosted
version: "4.9.1"
version: "4.9.2"
image_picker:
dependency: "direct main"
description:
@ -891,10 +891,10 @@ packages:
dependency: "direct main"
description:
name: material_ui
sha256: d9b4f6c69b80bc83d0a14357c86e4c14c8076e807ae73cf2960c8560f623995f
sha256: "4f3f38b9953df0a87d6bf5f21880029f77c47048487d5339410c39936be4683b"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
version: "1.0.1"
measure_size:
dependency: "direct main"
description:
@ -1188,10 +1188,10 @@ packages:
dependency: transitive
description:
name: record_use
sha256: "3b4ab682aff40175afca6ff090cc5aa7ce9dafe8dfbae1537a6c678e6678baee"
sha256: "1cb8564af8d43b464294411db9217f5ec04891c6f22ee2c32d73ae05e88a6bd2"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
riverpod:
dependency: transitive
description:
@ -1393,10 +1393,10 @@ packages:
dependency: transitive
description:
name: source_maps
sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812"
sha256: "14c2945847669b44089bb1222f66873d7ff7103c58911917f2a63c5a62327898"
url: "https://pub.dev"
source: hosted
version: "0.10.13"
version: "0.10.14"
source_span:
dependency: transitive
description:
@ -1633,10 +1633,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360"
sha256: "5f37239c4851efcef929cea7824e76df7f2f0970aef85d66bbc430afa40e72f0"
url: "https://pub.dev"
source: hosted
version: "15.2.0"
version: "15.3.0"
wakelock_plus:
dependency: transitive
description:

View file

@ -1,5 +1,5 @@
name: nexus
description: "Yet another Matrix client"
description: "A simple and user-friendly Matrix client"
version: 0.1.0
publish_to: none
@ -15,7 +15,7 @@ flutter:
- assets/
environment:
sdk: "3.13.0"
sdk: 3.13.0
dependency_overrides:
path_provider_android: 2.2.23 # Pinned to avoid JNI
@ -50,7 +50,7 @@ dependencies:
dynamic_polls: 0.0.8
flutter_hooks: 0.21.3+1
ffi: 2.2.0
hooks: 2.1.0
hooks: ^2.2.0
code_assets: 1.2.1
ffigen: 21.0.0
timeago: 3.7.1
@ -76,12 +76,12 @@ dependencies:
package_info_plus: 10.2.1
app_links: 7.2.1
file_selector: 1.1.0
material_ui: 1.0.0
material_ui: 1.0.1
dev_dependencies:
build_runner: 2.16.0
flutter_lints: 6.0.0
freezed: 4.0.0-dev.3
freezed: 4.0.0
riverpod_lint: 3.1.8
flutter_launcher_icons: 0.14.4
json_serializable: 6.14.1