diff --git a/analysis_options.yaml b/analysis_options.yaml index 52d1da54..9bd6a2d4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,8 +2,6 @@ include: - package:flutter_lints/flutter.yaml analyzer: - errors: - invalid_annotation_target: ignore language: strict-casts: true strict-raw-types: true diff --git a/lib/src/core/network/atproto/data/models/feed_models.dart b/lib/src/core/network/atproto/data/models/feed_models.dart index ef2ccfa9..c4d3b5fa 100644 --- a/lib/src/core/network/atproto/data/models/feed_models.dart +++ b/lib/src/core/network/atproto/data/models/feed_models.dart @@ -50,7 +50,6 @@ typedef ThreadContext = sprk_feed_defs.ThreadContext; /// The feeds that are actually used in the app @freezed abstract class Feed with _$Feed { - @JsonSerializable(explicitToJson: true) factory Feed({ required String type, required SavedFeed config, @@ -65,7 +64,6 @@ abstract class Feed with _$Feed { sealed class HardcodedFeedExtraInfo with _$HardcodedFeedExtraInfo { const HardcodedFeedExtraInfo._(); - @JsonSerializable(explicitToJson: true) const factory HardcodedFeedExtraInfo.shared({ required ProfileViewBasic from, String? message, @@ -415,7 +413,6 @@ extension PostViewConvenience on PostView { @freezed abstract class ImageUploadResult with _$ImageUploadResult { - @JsonSerializable(explicitToJson: true) const factory ImageUploadResult({ required String fullsize, required String alt, @@ -429,7 +426,6 @@ abstract class ImageUploadResult with _$ImageUploadResult { @freezed abstract class CaptionRef with _$CaptionRef { - @JsonSerializable(explicitToJson: true) const factory CaptionRef({ required String text, @Default([]) List facets, @@ -443,7 +439,6 @@ abstract class CaptionRef with _$CaptionRef { /// Represents the index range for a facet in the text @freezed abstract class FacetIndex with _$FacetIndex { - @JsonSerializable(explicitToJson: true) const factory FacetIndex({ /// Start index (inclusive) required int byteStart, @@ -466,36 +461,30 @@ abstract class FacetFeature with _$FacetFeature { // Spark facet feature types /// Mention feature for referencing a user @FreezedUnionValue('#mention') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.mention({required String did}) = MentionFeature; /// Link feature for URLs @FreezedUnionValue('#link') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.link({@AtUriConverter() required Uri uri}) = LinkFeature; /// Tag feature for hashtags @FreezedUnionValue('#tag') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.tag({required String tag}) = TagFeature; // Bluesky facet feature types /// Bluesky mention feature for referencing a user @FreezedUnionValue('app.bsky.richtext.facet#mention') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.bskyMention({required String did}) = BskyMentionFeature; /// Bluesky link feature for URLs @FreezedUnionValue('app.bsky.richtext.facet#link') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.bskyLink({@AtUriConverter() required AtUri uri}) = BskyLinkFeature; /// Bluesky tag feature for hashtags @FreezedUnionValue('app.bsky.richtext.facet#tag') - @JsonSerializable(explicitToJson: true) const factory FacetFeature.bskyTag({required String tag}) = BskyTagFeature; /// Create a FacetFeature from JSON @@ -506,7 +495,6 @@ abstract class FacetFeature with _$FacetFeature { /// Represents a richtext facet for text formatting, mentions, links, etc. @freezed abstract class Facet with _$Facet { - @JsonSerializable(explicitToJson: true) const factory Facet({ /// Index range for the facet in the text required FacetIndex index, @@ -525,11 +513,9 @@ sealed class ThreadPost with _$ThreadPost { const ThreadPost._(); @FreezedUnionValue('so.sprk.feed.defs#postView') - @JsonSerializable(explicitToJson: true) const factory ThreadPost.post({required PostView post}) = ThreadPostView; @FreezedUnionValue('so.sprk.feed.defs#replyView') - @JsonSerializable(explicitToJson: true) const factory ThreadPost.reply({required ReplyView reply}) = ThreadReplyView; factory ThreadPost.fromJson(Map json) => @@ -612,7 +598,6 @@ sealed class Thread with _$Thread { // NORMAL POST @FreezedUnionValue('so.sprk.feed.defs#threadViewPost') - @JsonSerializable(explicitToJson: true) const factory Thread.threadViewPost({ required ThreadPost post, Thread? parent, @@ -622,7 +607,6 @@ sealed class Thread with _$Thread { // NOT FOUND POST @FreezedUnionValue('so.sprk.feed.defs#notFoundPost') - @JsonSerializable(explicitToJson: true) const factory Thread.notFoundPost({ @AtUriConverter() required AtUri uri, required bool notFound, @@ -630,7 +614,6 @@ sealed class Thread with _$Thread { // BLOCKED POST @FreezedUnionValue('so.sprk.feed.defs#blockedPost') - @JsonSerializable(explicitToJson: true) const factory Thread.blockedPost({ @AtUriConverter() required AtUri uri, required bool blocked, diff --git a/lib/src/core/network/atproto/data/models/labeler_models.dart b/lib/src/core/network/atproto/data/models/labeler_models.dart index 47865a3f..ab1d5f40 100644 --- a/lib/src/core/network/atproto/data/models/labeler_models.dart +++ b/lib/src/core/network/atproto/data/models/labeler_models.dart @@ -73,7 +73,6 @@ enum Setting { @freezed abstract class LabelPreference with _$LabelPreference { - @JsonSerializable(explicitToJson: true) factory LabelPreference({ required String value, required Blurs blurs, diff --git a/lib/src/core/network/atproto/data/models/record_models.dart b/lib/src/core/network/atproto/data/models/record_models.dart index ca3c4c85..e5e791fc 100644 --- a/lib/src/core/network/atproto/data/models/record_models.dart +++ b/lib/src/core/network/atproto/data/models/record_models.dart @@ -22,7 +22,7 @@ typedef PlyrFeaturedArtist = plyr_track.FeaturedArtist; abstract class Record with _$Record { factory Record.fromJson(Map json) => _$RecordFromJson(json); const Record._(); - @JsonSerializable(explicitToJson: true) + @FreezedUnionValue('so.sprk.feed.post') const factory Record.post({ required CaptionRef caption, @@ -36,7 +36,6 @@ abstract class Record with _$Record { RepoStrongRef? sound, }) = PostRecord; - @JsonSerializable(explicitToJson: true) @FreezedUnionValue('so.sprk.feed.reply') const factory Record.reply({ required CaptionRef caption, @@ -47,7 +46,6 @@ abstract class Record with _$Record { Media? media, }) = ReplyRecord; - @JsonSerializable(explicitToJson: true) @FreezedUnionValue('app.bsky.feed.post') const factory Record.bskyPost({ DateTime? createdAt, @@ -95,7 +93,6 @@ extension StoryRecordConvenience on StoryRecord { /// Skeleton of a ReplyRef. Needs to be hydrated. @freezed abstract class RecordReplyRef with _$RecordReplyRef { - @JsonSerializable(explicitToJson: true) const factory RecordReplyRef({ required RepoStrongRef root, required RepoStrongRef parent, @@ -112,42 +109,34 @@ sealed class Media with _$Media { // Spark media types (new schema) @FreezedUnionValue('so.sprk.media.video') - @JsonSerializable(explicitToJson: true) const factory Media.video({required Blob video, String? alt}) = MediaVideo; @FreezedUnionValue('so.sprk.media.image') - @JsonSerializable(explicitToJson: true) const factory Media.image({required Blob image, String? alt}) = MediaImage; @FreezedUnionValue('so.sprk.media.images') - @JsonSerializable(explicitToJson: true) const factory Media.images({required List images}) = MediaImages; // Bluesky embed types @FreezedUnionValue('app.bsky.embed.video') - @JsonSerializable(explicitToJson: true) const factory Media.bskyVideo({required Blob video, String? alt}) = MediaBskyVideo; @FreezedUnionValue('app.bsky.embed.images') - @JsonSerializable(explicitToJson: true) const factory Media.bskyImages({required List images}) = MediaBskyImages; @FreezedUnionValue('app.bsky.embed.record') - @JsonSerializable(explicitToJson: true) const factory Media.bskyRecord({required RepoStrongRef record}) = MediaBskyRecord; @FreezedUnionValue('app.bsky.embed.recordWithMedia') - @JsonSerializable(explicitToJson: true) const factory Media.bskyRecordWithMedia({ required MediaBskyRecord record, required Media media, }) = MediaBskyRecordWithMedia; @FreezedUnionValue('app.bsky.embed.external') - @JsonSerializable(explicitToJson: true) const factory Media.bskyExternal({required EmbedExternal external}) = MediaBskyExternal; @@ -156,7 +145,6 @@ sealed class Media with _$Media { @freezed abstract class EmbedExternal with _$EmbedExternal { - @JsonSerializable(explicitToJson: true) const factory EmbedExternal({ required String uri, @Default('') String title, @@ -171,7 +159,6 @@ abstract class EmbedExternal with _$EmbedExternal { @freezed abstract class Image with _$Image { - @JsonSerializable(explicitToJson: true) const factory Image({ required Blob image, String? alt, diff --git a/lib/src/core/network/messages/data/models/message_models.dart b/lib/src/core/network/messages/data/models/message_models.dart index 10469a2c..ba7706fd 100644 --- a/lib/src/core/network/messages/data/models/message_models.dart +++ b/lib/src/core/network/messages/data/models/message_models.dart @@ -6,7 +6,6 @@ part 'message_models.g.dart'; @freezed abstract class Embed with _$Embed { - @JsonSerializable(explicitToJson: true) const factory Embed({String? url, String? type, String? preview}) = _Embed; const Embed._(); @@ -18,7 +17,6 @@ abstract class Embed with _$Embed { @freezed abstract class Message with _$Message { - @JsonSerializable(explicitToJson: true) const factory Message({ required int id, @JsonKey(name: 'sender_did') required String senderDid, @@ -37,7 +35,6 @@ abstract class Message with _$Message { @freezed abstract class SenderView with _$SenderView { - @JsonSerializable(explicitToJson: true) const factory SenderView({required String did}) = _SenderView; const SenderView._(); @@ -47,7 +44,6 @@ abstract class SenderView with _$SenderView { @freezed abstract class ReactionView with _$ReactionView { - @JsonSerializable(explicitToJson: true) const factory ReactionView({ required String value, required SenderView sender, @@ -61,7 +57,6 @@ abstract class ReactionView with _$ReactionView { @freezed abstract class MessageView with _$MessageView { - @JsonSerializable(explicitToJson: true) const factory MessageView({ required String id, required String rev, @@ -79,7 +74,6 @@ abstract class MessageView with _$MessageView { @freezed abstract class DeletedMessageView with _$DeletedMessageView { - @JsonSerializable(explicitToJson: true) const factory DeletedMessageView({ required String id, required String rev, @@ -94,7 +88,6 @@ abstract class DeletedMessageView with _$DeletedMessageView { @freezed abstract class ConvoView with _$ConvoView { - @JsonSerializable(explicitToJson: true) const factory ConvoView({ required String id, required String rev, diff --git a/lib/src/core/utils/logging/file_output.dart b/lib/src/core/utils/logging/file_output.dart index da794ea8..bd6b780e 100644 --- a/lib/src/core/utils/logging/file_output.dart +++ b/lib/src/core/utils/logging/file_output.dart @@ -1,5 +1,4 @@ -// ignore_for_file: avoid_print - +import 'dart:developer' as developer; import 'dart:io'; import 'package:path_provider/path_provider.dart'; @@ -41,8 +40,12 @@ class FileOutput implements LogOutput { await Directory(path).create(recursive: true); _file = File('$path/$_fileName'); _initialized = true; - } catch (e) { - print('Failed to initialize file logging: $e'); + } catch (e, stackTrace) { + _reportFileLoggingFailure( + 'Failed to initialize file logging', + e, + stackTrace, + ); } } @@ -87,8 +90,8 @@ class FileOutput implements LogOutput { mode: FileMode.append, flush: true, // Ensure it's written immediately ); - } catch (e) { - print('Failed to write to log file: $e'); + } catch (e, stackTrace) { + _reportFileLoggingFailure('Failed to write to log file', e, stackTrace); } }); } @@ -136,8 +139,22 @@ class FileOutput implements LogOutput { await _file!.rename(newFilePath); _file = File(oldFilePath); - } catch (e) { - print('Failed to rotate log file: $e'); + } catch (e, stackTrace) { + _reportFileLoggingFailure('Failed to rotate log file', e, stackTrace); } } + + void _reportFileLoggingFailure( + String message, + Object error, + StackTrace stackTrace, + ) { + developer.log( + message, + name: 'FileOutput', + level: LogLevel.error.value * 100, + error: error, + stackTrace: stackTrace, + ); + } }