fix freezed definitions
This commit is contained in:
parent
baad7b08a8
commit
78744135c9
51 changed files with 540 additions and 320 deletions
|
|
@ -2,6 +2,7 @@ analyzer:
|
|||
errors:
|
||||
invalid_annotation_target: ignore
|
||||
avoid_print: ignore
|
||||
annotate_overrides: ignore
|
||||
exclude:
|
||||
- "build/**"
|
||||
- "**/*.g.dart"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue