Skip to content

Commit 0b0feb6

Browse files
committed
style: misc
1 parent 7419e8b commit 0b0feb6

File tree

13 files changed

+65
-47
lines changed

13 files changed

+65
-47
lines changed

lib/src/models/feed/feed_item_action.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ Map<String, dynamic> feedItemActionToJson(FeedItemAction action) {
5959
/// {@endtemplate}
6060
@JsonSerializable()
6161
class OpenInternalContent extends FeedItemAction {
62+
63+
/// Factory method to create an [OpenInternalContent] instance from a JSON map.
64+
factory OpenInternalContent.fromJson(Map<String, dynamic> json) =>
65+
_$OpenInternalContentFromJson(json);
6266
/// {@macro open_internal_content}
6367
const OpenInternalContent({
6468
required this.contentId,
@@ -69,10 +73,6 @@ class OpenInternalContent extends FeedItemAction {
6973
@JsonKey(name: 'type', required: true)
7074
final String type;
7175

72-
/// Factory method to create an [OpenInternalContent] instance from a JSON map.
73-
factory OpenInternalContent.fromJson(Map<String, dynamic> json) =>
74-
_$OpenInternalContentFromJson(json);
75-
7676
/// The unique identifier of the internal content to open.
7777
final String contentId;
7878

@@ -88,6 +88,13 @@ class OpenInternalContent extends FeedItemAction {
8888
/// {@endtemplate}
8989
@JsonSerializable()
9090
class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
91+
92+
/// Factory method to create a [ShowInterstitialThenOpenInternalContent]
93+
/// instance from a JSON map.
94+
factory ShowInterstitialThenOpenInternalContent.fromJson(
95+
Map<String, dynamic> json,
96+
) =>
97+
_$ShowInterstitialThenOpenInternalContentFromJson(json);
9198
/// {@macro show_interstitial_then_open_internal_content}
9299
const ShowInterstitialThenOpenInternalContent({
93100
required this.contentId,
@@ -98,13 +105,6 @@ class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
98105
@JsonKey(name: 'type', required: true)
99106
final String type;
100107

101-
/// Factory method to create a [ShowInterstitialThenOpenInternalContent]
102-
/// instance from a JSON map.
103-
factory ShowInterstitialThenOpenInternalContent.fromJson(
104-
Map<String, dynamic> json,
105-
) =>
106-
_$ShowInterstitialThenOpenInternalContentFromJson(json);
107-
108108
/// The unique identifier of the internal content to open after the interstitial.
109109
final String contentId;
110110

@@ -121,17 +121,17 @@ class ShowInterstitialThenOpenInternalContent extends FeedItemAction {
121121
/// {@endtemplate}
122122
@JsonSerializable()
123123
class OpenExternalUrl extends FeedItemAction {
124+
125+
/// Factory method to create an [OpenExternalUrl] instance from a JSON map.
126+
factory OpenExternalUrl.fromJson(Map<String, dynamic> json) =>
127+
_$OpenExternalUrlFromJson(json);
124128
/// {@macro open_external_url}
125129
const OpenExternalUrl({required this.url}) : type = 'open_external_url';
126130

127131
/// A string representation of the action type.
128132
@JsonKey(name: 'type', required: true)
129133
final String type;
130134

131-
/// Factory method to create an [OpenExternalUrl] instance from a JSON map.
132-
factory OpenExternalUrl.fromJson(Map<String, dynamic> json) =>
133-
_$OpenExternalUrlFromJson(json);
134-
135135
/// The URL to open.
136136
final String url;
137137

lib/src/models/news/source.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class Source extends FeedItem {
4848
/// The type of the source (e.g., newsAgency, blog).
4949
/// If an unknown value is encountered during deserialization,
5050
/// this field will be set to null.
51-
@JsonKey(name: 'sourceType', unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
51+
@JsonKey(
52+
name: 'sourceType', unknownEnumValue: JsonKey.nullForUndefinedEnumValue,)
5253
final SourceType? _sourceType;
5354

5455
/// Public getter for the source type.
@@ -61,6 +62,7 @@ class Source extends FeedItem {
6162
final Country? headquarters;
6263

6364
/// The action to be performed when this feed item is interacted with.
65+
@override
6466
@JsonKey(fromJson: feedItemActionFromJson, toJson: feedItemActionToJson)
6567
final FeedItemAction action;
6668

test/src/models/feed/ad_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void main() {
3434

3535
group('constructor', () {
3636
test('generates id when not provided', () {
37-
final ad = createSubject(id: null);
37+
final ad = createSubject();
3838
expect(ad.id, isA<String>());
3939
expect(Uuid.isValidUUID(fromString: ad.id), isTrue);
4040
});

test/src/models/feed/engagement_content_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main() {
3737

3838
group('constructor', () {
3939
test('generates id when not provided', () {
40-
final content = createSubject(id: null);
40+
final content = createSubject();
4141
expect(content.id, isA<String>());
4242
expect(Uuid.isValidUUID(fromString: content.id), isTrue);
4343
});

test/src/models/feed/feed_item_action_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void main() {
187187
final action = feedItemActionFromJson(json);
188188
expect(action, isA<ShowInterstitialThenOpenInternalContent>());
189189
expect((action as ShowInterstitialThenOpenInternalContent).contentId,
190-
'id2');
190+
'id2',);
191191
expect(action.contentType, ContentType.category);
192192
});
193193

@@ -209,7 +209,7 @@ void main() {
209209
(e) => e.message,
210210
'message',
211211
'Missing "type" field in FeedItemAction JSON.',
212-
)),
212+
),),
213213
);
214214
});
215215

@@ -221,7 +221,7 @@ void main() {
221221
(e) => e.message,
222222
'message',
223223
'Unknown FeedItemAction type: unknown_type',
224-
)),
224+
),),
225225
);
226226
});
227227
});

test/src/models/feed/feed_item_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void main() {
124124
(e) => e.message,
125125
'message',
126126
'Missing "type" field in FeedItem JSON.',
127-
)),
127+
),),
128128
);
129129
});
130130

@@ -136,7 +136,7 @@ void main() {
136136
(e) => e.message,
137137
'message',
138138
'Unknown FeedItem type: unknown_type',
139-
)),
139+
),),
140140
);
141141
});
142142
});

test/src/models/feed/source_type_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ void main() {
77
expect(SourceType.newsAgency.name, 'newsAgency');
88
expect(SourceType.localNewsOutlet.name, 'localNewsOutlet');
99
expect(SourceType.nationalNewsOutlet.name, 'nationalNewsOutlet');
10-
expect(SourceType.internationalNewsOutlet.name, 'internationalNewsOutlet');
10+
expect(
11+
SourceType.internationalNewsOutlet.name, 'internationalNewsOutlet',);
1112
expect(SourceType.specializedPublisher.name, 'specializedPublisher');
1213
expect(SourceType.blog.name, 'blog');
1314
expect(SourceType.governmentSource.name, 'governmentSource');

test/src/models/feed/suggested_content_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void main() {
6868

6969
group('constructor', () {
7070
test('generates id when not provided', () {
71-
final content = createSubject(id: null);
71+
final content = createSubject();
7272
expect(content.id, isA<String>());
7373
expect(Uuid.isValidUUID(fromString: content.id), isTrue);
7474
});

test/src/models/news/headline_test.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,20 @@ void main() {
181181

182182
group('Equatable', () {
183183
test('should equate two identical instances', () {
184-
final headline1 = Headline(id: '1', title: 'Title', action: defaultAction);
185-
final headline2 = Headline(id: '1', title: 'Title', action: defaultAction);
184+
final headline1 =
185+
Headline(id: '1', title: 'Title', action: defaultAction);
186+
final headline2 =
187+
Headline(id: '1', title: 'Title', action: defaultAction);
186188
expect(headline1, equals(headline2));
187189
});
188190

189191
test('should not equate instances with different properties', () {
190-
final headline1 = Headline(id: '1', title: 'Title 1', action: defaultAction);
191-
final headline2 = Headline(id: '1', title: 'Title 2', action: defaultAction);
192-
final headline3 = Headline(id: '2', title: 'Title 1', action: defaultAction);
192+
final headline1 =
193+
Headline(id: '1', title: 'Title 1', action: defaultAction);
194+
final headline2 =
195+
Headline(id: '1', title: 'Title 2', action: defaultAction);
196+
final headline3 =
197+
Headline(id: '2', title: 'Title 1', action: defaultAction);
193198
expect(headline1, isNot(equals(headline2)));
194199
expect(headline1, isNot(equals(headline3)));
195200
});

test/src/models/news/source_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ void main() {
115115
});
116116

117117
test('instances with different props are not equal', () {
118-
final source1 = Source(id: testId, name: testName, action: defaultAction);
118+
final source1 =
119+
Source(id: testId, name: testName, action: defaultAction);
119120
final source2 = Source(
120121
id: 'different-id', // Different ID
121122
name: testName,
@@ -163,14 +164,16 @@ void main() {
163164
expect(json['description'], testDescription);
164165
expect(json['url'], testUrl);
165166
expect(json['type'], 'source');
166-
expect(json['sourceType'], 'specialized-publisher'); // Use direct string
167+
expect(
168+
json['sourceType'], 'specialized-publisher',); // Use direct string
167169
expect(json['language'], testLanguage);
168170
expect(json['headquarters'], testHeadquartersJson);
169171
expect(json['action'], defaultAction.toJson());
170172
});
171173

172174
test('does not include null optional fields in JSON', () {
173-
final sourceWithNulls = Source(id: testId, name: testName, action: defaultAction);
175+
final sourceWithNulls =
176+
Source(id: testId, name: testName, action: defaultAction);
174177
final json = sourceWithNulls.toJson();
175178
expect(json.containsKey('description'), isFalse);
176179
expect(json.containsKey('url'), isFalse);

0 commit comments

Comments
 (0)