1- import 'package:equatable/equatable.dart' ;
21import 'package:ht_shared/ht_shared.dart'
32 show Category, Country, Headline, Source;
43import 'package:ht_shared/src/models/feed/feed_item.dart' ;
@@ -25,7 +24,8 @@ class SuggestedContent extends FeedItem {
2524 this .description,
2625 String ? id,
2726 }) : id = id ?? const Uuid ().v4 (),
28- super (type: 'suggested_content' ); // Removed action from super constructor
27+ super (
28+ type: 'suggested_content' ,); // Removed action from super constructor
2929
3030 /// Factory method to create a [SuggestedContent] instance from a JSON map.
3131 factory SuggestedContent .fromJson (Map <String , dynamic > json) {
@@ -36,24 +36,22 @@ class SuggestedContent extends FeedItem {
3636 displayType: suggestedContentDisplayTypeFromJson (
3737 json['displayType' ] as String ,
3838 ),
39- items: (json['items' ] as List <dynamic >)
40- .map ((e) {
41- final itemMap = e as Map <String , dynamic >;
42- final itemType = itemMap['type' ] as String ;
43- switch (itemType) {
44- case 'headline' :
45- return Headline .fromJson (itemMap);
46- case 'category' :
47- return Category .fromJson (itemMap);
48- case 'source' :
49- return Source .fromJson (itemMap);
50- case 'country' :
51- return Country .fromJson (itemMap);
52- default :
53- throw FormatException ('Unknown item type: $itemType ' );
54- }
55- })
56- .toList (),
39+ items: (json['items' ] as List <dynamic >).map ((e) {
40+ final itemMap = e as Map <String , dynamic >;
41+ final itemType = itemMap['type' ] as String ;
42+ switch (itemType) {
43+ case 'headline' :
44+ return Headline .fromJson (itemMap);
45+ case 'category' :
46+ return Category .fromJson (itemMap);
47+ case 'source' :
48+ return Source .fromJson (itemMap);
49+ case 'country' :
50+ return Country .fromJson (itemMap);
51+ default :
52+ throw FormatException ('Unknown item type: $itemType ' );
53+ }
54+ }).toList (),
5755 action: FeedItemAction .fromJson (json['action' ] as Map <String , dynamic >),
5856 );
5957 }
@@ -77,7 +75,7 @@ class SuggestedContent extends FeedItem {
7775 /// Converts this [SuggestedContent] instance to a JSON map.
7876 @override
7977 Map <String , dynamic > toJson () {
80- final Map <String , dynamic > json = {
78+ final json = < String , dynamic > {
8179 'id' : id,
8280 'title' : title,
8381 'description' : description,
@@ -92,7 +90,8 @@ class SuggestedContent extends FeedItem {
9290 } else if (e is Country ) {
9391 return e.toJson ();
9492 }
95- throw FormatException ('Unknown item type for serialization: ${e .runtimeType }' );
93+ throw FormatException (
94+ 'Unknown item type for serialization: ${e .runtimeType }' ,);
9695 }).toList (),
9796 'action' : action.toJson (),
9897 'type' : type, // Inherited from FeedItem
0 commit comments