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: errors:
invalid_annotation_target: ignore invalid_annotation_target: ignore
avoid_print: ignore avoid_print: ignore
annotate_overrides: ignore
exclude: exclude:
- "build/**" - "build/**"
- "**/*.g.dart" - "**/*.g.dart"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -31,7 +31,11 @@ enum RoomType {
} }
@freezed @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) => factory PreviousRoom.fromJson(Map<String, Object?> json) =>
_$PreviousRoomFromJson(json); _$PreviousRoomFromJson(json);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more