11import 'package:equatable/equatable.dart' ;
2- import 'package:ht_shared/ht_shared.dart' show FeedItem;
32import 'package:ht_shared/src/models/core/content_type.dart' ;
4- import 'package:ht_shared/src/models/core/feed_item.dart' show FeedItem;
5- import 'package:ht_shared/src/models/models.dart' show FeedItem;
6- // Removed redundant FeedItem imports
73import 'package:json_annotation/json_annotation.dart' ;
4+ import 'package:meta/meta.dart' ;
85
96part 'feed_item_action.g.dart' ;
107
@@ -15,7 +12,14 @@ part 'feed_item_action.g.dart';
1512/// and defined within this library. This allows for exhaustive pattern
1613/// matching in the UI layer.
1714/// {@endtemplate}
18- @JsonSerializable (createFactory: false )
15+ @immutable
16+ @JsonSerializable (
17+ createFactory: false ,
18+ fieldRename: FieldRename .snake,
19+ explicitToJson: true ,
20+ includeIfNull: false ,
21+ checked: true ,
22+ )
1923sealed class FeedItemAction extends Equatable {
2024 /// {@macro feed_item_action}
2125 const FeedItemAction ({required this .type});
@@ -66,7 +70,13 @@ Map<String, dynamic> feedItemActionToJson(FeedItemAction action) {
6670/// {@template open_internal_content}
6771/// An action to open content that resides within the application.
6872/// {@endtemplate}
69- @JsonSerializable ()
73+ @immutable
74+ @JsonSerializable (
75+ fieldRename: FieldRename .snake,
76+ explicitToJson: true ,
77+ includeIfNull: false ,
78+ checked: true ,
79+ )
7080class OpenInternalContent extends FeedItemAction {
7181 /// {@macro open_internal_content}
7282 const OpenInternalContent ({
@@ -82,6 +92,7 @@ class OpenInternalContent extends FeedItemAction {
8292 final String contentId;
8393
8494 /// The type of the internal content (e.g., headline, category, source).
95+ @JsonKey (unknownEnumValue: JsonKey .nullForUndefinedEnumValue)
8596 final ContentType contentType;
8697
8798 @override
@@ -99,7 +110,13 @@ class OpenInternalContent extends FeedItemAction {
99110/// {@template show_interstitial_then_open_internal_content}
100111/// An action to show an interstitial advertisement, then open internal content.
101112/// {@endtemplate}
102- @JsonSerializable ()
113+ @immutable
114+ @JsonSerializable (
115+ fieldRename: FieldRename .snake,
116+ explicitToJson: true ,
117+ includeIfNull: false ,
118+ checked: true ,
119+ )
103120class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
104121 /// {@macro show_interstitial_then_open_internal_content}
105122 const ShowInterstitialThenOpenInternalContent ({
@@ -118,6 +135,7 @@ class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
118135 final String contentId;
119136
120137 /// The type of the internal content (e.g., headline, category, source).
138+ @JsonKey (unknownEnumValue: JsonKey .nullForUndefinedEnumValue)
121139 final ContentType contentType;
122140
123141 @override
@@ -134,7 +152,13 @@ class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
134152/// {@template open_external_url}
135153/// An action to open an external URL, typically in a web browser.
136154/// {@endtemplate}
137- @JsonSerializable ()
155+ @immutable
156+ @JsonSerializable (
157+ fieldRename: FieldRename .snake,
158+ explicitToJson: true ,
159+ includeIfNull: false ,
160+ checked: true ,
161+ )
138162class OpenExternalUrl extends FeedItemAction {
139163 /// {@macro open_external_url}
140164 const OpenExternalUrl ({required this .url}) : super (type: 'open_external_url' );
0 commit comments