@@ -153,6 +153,20 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
153153 ),
154154 body: BlocBuilder <HeadlinesFeedBloc , HeadlinesFeedState >(
155155 builder: (context, state) {
156+ // Access the AppBloc to check for remoteConfig availability.
157+ final appBlocState = context.watch <AppBloc >().state;
158+
159+ // If remoteConfig is not yet loaded, show a loading indicator.
160+ // This handles the brief period after authentication but before
161+ // the remote config is fetched, preventing null access errors.
162+ if (appBlocState.remoteConfig == null ) {
163+ return LoadingStateWidget (
164+ icon: Icons .settings_applications_outlined,
165+ headline: l10n.headlinesFeedLoadingHeadline,
166+ subheadline: l10n.pleaseWait,
167+ );
168+ }
169+
156170 if (state.status == HeadlinesFeedStatus .initial ||
157171 (state.status == HeadlinesFeedStatus .loading &&
158172 state.feedItems.isEmpty)) {
@@ -175,14 +189,24 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
175189
176190 if (state.status == HeadlinesFeedStatus .success &&
177191 state.feedItems.isEmpty) {
178- return FailureStateWidget (
179- exception: const UnknownException (
180- 'No headlines found matching your criteria.' ,
181- ),
182- onRetry: () => context.read <HeadlinesFeedBloc >().add (
183- HeadlinesFeedFiltersCleared (),
192+ return Center (
193+ child: Column (
194+ mainAxisAlignment: MainAxisAlignment .center,
195+ children: [
196+ InitialStateWidget (
197+ icon: Icons .search_off,
198+ headline: l10n.headlinesFeedEmptyFilteredHeadline,
199+ subheadline: l10n.headlinesFeedEmptyFilteredSubheadline,
200+ ),
201+ const SizedBox (height: AppSpacing .lg),
202+ ElevatedButton (
203+ onPressed: () => context.read <HeadlinesFeedBloc >().add (
204+ HeadlinesFeedFiltersCleared (),
205+ ),
206+ child: Text (l10n.headlinesFeedClearFiltersButton),
207+ ),
208+ ],
184209 ),
185- retryButtonText: l10n.headlinesFeedClearFiltersButton,
186210 );
187211 }
188212
0 commit comments