Skip to content

Commit 9a2a7db

Browse files
committed
fix(headlines-search): improve null safety and localization
- Replace null checks with isEmpty checks for description and callToActionText - Remove unused _getHintTextForModelType method - Update TODO comment about localization extension
1 parent 9084202 commit 9a2a7db

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

lib/headlines-search/view/headlines_search_page.dart

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:ht_main/app/bloc/app_bloc.dart';
99
import 'package:ht_main/headlines-search/bloc/headlines_search_bloc.dart';
1010
// import 'package:ht_main/headlines-search/widgets/country_item_widget.dart';
1111
import 'package:ht_main/headlines-search/widgets/source_item_widget.dart';
12-
import 'package:ht_main/l10n/app_localizations.dart';
1312
import 'package:ht_main/l10n/l10n.dart';
1413
import 'package:ht_main/router/routes.dart';
1514
import 'package:ht_main/shared/extensions/content_type_extensions.dart';
@@ -401,7 +400,7 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
401400
fontWeight: FontWeight.bold,
402401
),
403402
),
404-
subtitle: feedItem.description != null
403+
subtitle: feedItem.description.isNotEmpty
405404
? Text(
406405
feedItem.description,
407406
style: currentTextTheme.bodySmall
@@ -412,7 +411,7 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
412411
),
413412
)
414413
: null,
415-
trailing: feedItem.callToActionText != null
414+
trailing: feedItem.callToActionText.isNotEmpty
416415
? ElevatedButton(
417416
style: ElevatedButton.styleFrom(
418417
backgroundColor:
@@ -464,21 +463,4 @@ class _HeadlinesSearchViewState extends State<_HeadlinesSearchView> {
464463
);
465464
}
466465

467-
// TODO(user): This method should be removed and replaced with a localization extension.
468-
String _getHintTextForModelType(
469-
ContentType modelType,
470-
AppLocalizations l10n,
471-
) {
472-
// The switch is now exhaustive for the remaining SearchModelType values
473-
switch (modelType) {
474-
case ContentType.headline:
475-
return l10n.searchHintTextHeadline;
476-
case ContentType.topic:
477-
return l10n.searchHintTextCategory;
478-
case ContentType.source:
479-
return l10n.searchHintTextSource;
480-
default:
481-
return 'Search...';
482-
}
483-
}
484466
}

0 commit comments

Comments
 (0)