Skip to content

Commit 000ac85

Browse files
committed
fix(feed): resolve type error on returning from multi-select page
Fixes a `_TypeError` that occurred when popping the `MultiSelectSearchPage`. The error was caused by a type mismatch between the `Set<dynamic>` returned by the generic page and the `Future<Set<Country>>` expected by the calling page. The solution is to change the expected return type of `pushNamed` to `Set<dynamic>` and then safely cast the resulting set to `Set<Country>` before updating the state. This ensures type safety and resolves the runtime crash.
1 parent 8ec4dba commit 000ac85

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/headlines-feed/view/source_list_filter_page.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class _SourceListFilterPageState extends State<SourceListFilterPage> {
9595
),
9696
trailing: const Icon(Icons.chevron_right),
9797
onTap: () async {
98-
final result = await context.pushNamed<Set<Country>>(
98+
final result = await context.pushNamed<Set<dynamic>>(
9999
Routes.multiSelectSearchName,
100100
extra: {
101101
'title': l10n.headlinesFeedFilterSourceCountryLabel,
@@ -106,7 +106,9 @@ class _SourceListFilterPageState extends State<SourceListFilterPage> {
106106
);
107107

108108
if (result != null && mounted) {
109-
setState(() => _selectedHeadquarterCountries = result);
109+
setState(
110+
() => _selectedHeadquarterCountries = result.cast<Country>(),
111+
);
110112
}
111113
},
112114
),

0 commit comments

Comments
 (0)