Skip to content

Commit 2b64c87

Browse files
committed
refactor: forced @JsonEnum Annotations constrains
1 parent 8423a23 commit 2b64c87

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

lib/src/models/feed_decorators/engagement_content_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:json_annotation/json_annotation.dart';
99
/// {@template engagement_content_type}
1010
/// Defines the specific type or purpose of an [EngagementContent] item.
1111
/// {@endtemplate}
12-
@JsonEnum(fieldRename: FieldRename.kebab)
12+
@JsonEnum(fieldRename: FieldRename.snake)
1313
enum EngagementContentType {
1414
/// A call-to-action to sign up for an account.
1515
signUp,

lib/src/models/feed_decorators/suggested_content_display_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:json_annotation/json_annotation.dart';
1313
/// This enum guides the UI on how to render the list of items
1414
/// contained within a SuggestedContent model.
1515
/// {@endtemplate}
16-
@JsonEnum(fieldRename: FieldRename.kebab)
16+
@JsonEnum(fieldRename: FieldRename.snake)
1717
enum SuggestedContentDisplayType {
1818
/// Displays content items in a horizontally scrollable list of cards.
1919
horizontalCardList,

lib/src/models/feed_extras/feed_template_types.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:json_annotation/json_annotation.dart';
33
/// Defines the types of engagement content templates available.
44
/// The string value of the enum (e.g., 'rate-app') will be used as the ID
55
/// to link rules in AppConfig to specific EngagementContentTemplate instances.
6-
@JsonEnum(fieldRename: FieldRename.kebab)
6+
@JsonEnum(fieldRename: FieldRename.snake)
77
enum EngagementTemplateType {
88
/// Prompt to rate the application.
99
rateApp,
@@ -24,7 +24,7 @@ enum EngagementTemplateType {
2424
/// Defines the types of suggested content templates available.
2525
/// The string value of the enum (e.g., 'categories-to-follow') will be used as the ID
2626
/// to link rules in AppConfig to specific SuggestedContentTemplate instances.
27-
@JsonEnum(fieldRename: FieldRename.kebab)
27+
@JsonEnum(fieldRename: FieldRename.snake)
2828
enum SuggestionTemplateType {
2929
/// Suggest categories to follow.
3030
categoriesToFollow,

lib/src/models/user_settings/feed_display_preferences.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:meta/meta.dart';
34

45
part 'feed_display_preferences.g.dart';
56

@@ -30,7 +31,13 @@ enum HeadlineImageStyle {
3031
/// {@template feed_display_preferences}
3132
/// User preferences for how feeds are displayed.
3233
/// {@endtemplate}
33-
@JsonSerializable()
34+
@immutable
35+
@JsonSerializable(
36+
fieldRename: FieldRename.snake,
37+
explicitToJson: true,
38+
includeIfNull: false,
39+
checked: true,
40+
)
3441
class FeedDisplayPreferences extends Equatable {
3542
/// {@macro feed_display_preferences}
3643
const FeedDisplayPreferences({
@@ -45,9 +52,11 @@ class FeedDisplayPreferences extends Equatable {
4552
_$FeedDisplayPreferencesFromJson(json);
4653

4754
/// How densely headline information should be presented.
55+
@JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
4856
final HeadlineDensity headlineDensity;
4957

5058
/// How images should be displayed in the headline feed.
59+
@JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
5160
final HeadlineImageStyle headlineImageStyle;
5261

5362
/// Whether to show the source name directly in the headline feed item.

0 commit comments

Comments
 (0)