Skip to content

Commit f159c03

Browse files
committed
refactor(headlines_feed): remove dead code from feed page
Removes the unreachable `if` branches for `CallToActionItem` and `ContentCollectionItem` from the `itemBuilder` in `HeadlinesFeedPage`. The rendering of these decorators is now fully encapsulated within the `FeedDecoratorLoaderWidget`, which is built when a `DecoratorPlaceholder` is encountered. This change cleans up the rendering logic and removes dead code. A `ValueKey` is also added to the `FeedDecoratorLoaderWidget` to ensure its state is managed correctly within the list.
1 parent 8268dc2 commit f159c03

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,16 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage>
315315
adThemeStyle: AdThemeStyle.fromTheme(theme),
316316
adConfig: adConfig,
317317
);
318-
} else if (item is CallToActionItem) {
319-
// This case is now handled by FeedDecoratorLoaderWidget.
320-
return const SizedBox.shrink();
321-
} else if (item is ContentCollectionItem) {
322-
// This case is now handled by FeedDecoratorLoaderWidget.
323-
return const SizedBox.shrink();
324318
} else if (item is DecoratorPlaceholder) {
325-
return const FeedDecoratorLoaderWidget();
319+
// The FeedDecoratorLoaderWidget is responsible for
320+
// determining which non-ad decorator to show and
321+
// managing its entire lifecycle. A ValueKey is
322+
// used to ensure its state is preserved correctly.
323+
return FeedDecoratorLoaderWidget(
324+
key: ValueKey(item.id),
325+
);
326326
}
327+
// Return an empty box for any other unhandled item types.
327328
return const SizedBox.shrink();
328329
},
329330
),

0 commit comments

Comments
 (0)