Skip to content

Commit 39e66c5

Browse files
committed
refactor(router): use named routes for entity details
- Replace direct navigation to entity details pages with a single named route - Use path parameters to specify entity type and ID - Remove unnecessary imports of EntityDetailsPage - Update navigation in followed items pages (countries, sources, topics)
1 parent a2ce738 commit 39e66c5

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

lib/account/view/manage_followed_items/countries/followed_countries_list_page.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
5-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
65
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
76
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
87
import 'package:go_router/go_router.dart';
@@ -97,12 +96,12 @@ class FollowedCountriesListPage extends StatelessWidget {
9796
},
9897
),
9998
onTap: () {
100-
context.push(
101-
Routes.countryDetails,
102-
extra: EntityDetailsPageArguments(
103-
entityId: country.id,
104-
contentType: ContentType.country,
105-
),
99+
context.pushNamed(
100+
Routes.entityDetailsName,
101+
pathParameters: {
102+
'type': ContentType.country.name, // 'topic'
103+
'id': country.id,
104+
},
106105
);
107106
},
108107
);

lib/account/view/manage_followed_items/sources/followed_sources_list_page.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
5-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
65
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
76
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
87
import 'package:go_router/go_router.dart';
@@ -94,12 +93,12 @@ class FollowedSourcesListPage extends StatelessWidget {
9493
},
9594
),
9695
onTap: () {
97-
context.push(
98-
Routes.sourceDetails,
99-
extra: EntityDetailsPageArguments(
100-
entityId: source.id,
101-
contentType: ContentType.source,
102-
),
96+
context.pushNamed(
97+
Routes.entityDetailsName,
98+
pathParameters: {
99+
'type': ContentType.source.name,
100+
'id': source.id,
101+
},
103102
);
104103
},
105104
);

lib/account/view/manage_followed_items/topics/followed_topics_list_page.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
5-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
65
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
76
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
87
import 'package:go_router/go_router.dart';
@@ -102,12 +101,12 @@ class FollowedTopicsListPage extends StatelessWidget {
102101
},
103102
),
104103
onTap: () {
105-
context.push(
106-
Routes.topicDetails,
107-
extra: EntityDetailsPageArguments(
108-
entityId: topic.id,
109-
contentType: ContentType.topic,
110-
),
104+
context.pushNamed(
105+
Routes.entityDetailsName,
106+
pathParameters: {
107+
'type': ContentType.topic.name,
108+
'id': topic.id,
109+
},
111110
);
112111
},
113112
);

0 commit comments

Comments
 (0)