Skip to content

Commit cd83cd2

Browse files
committed
refactor(router): replace push method with pushNamed for entity details
- Remove direct imports of EntityDetailsPage - Update onTap handlers to use context.pushNamed instead of context.push - Pass entity type and ID as path parameters to entityDetailsName route - Affected widgets: CategoryItemWidget, CountryItemWidget, SourceItemWidget, TopicItemWidget
1 parent cc1c9de commit cd83cd2

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

lib/headlines-search/widgets/category_item_widget.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
43
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
54
import 'package:go_router/go_router.dart';
65

@@ -22,12 +21,9 @@ class TopicItemWidget extends StatelessWidget {
2221
)
2322
: null,
2423
onTap: () {
25-
context.push(
26-
Routes.topicDetails,
27-
extra: EntityDetailsPageArguments(
28-
entityId: topic.id,
29-
contentType: ContentType.topic,
30-
),
24+
context.pushNamed(
25+
Routes.entityDetailsName,
26+
pathParameters: {'type': ContentType.topic.name, 'id': topic.id},
3127
);
3228
},
3329
);

lib/headlines-search/widgets/country_item_widget.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
43
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
54
import 'package:go_router/go_router.dart';
65

@@ -21,12 +20,9 @@ class CountryItemWidget extends StatelessWidget {
2120
? Text(country.isoCode, maxLines: 1, overflow: TextOverflow.ellipsis)
2221
: null,
2322
onTap: () {
24-
context.push(
25-
Routes.countryDetails,
26-
extra: EntityDetailsPageArguments(
27-
entityId: country.id,
28-
contentType: ContentType.country,
29-
),
23+
context.pushNamed(
24+
Routes.entityDetailsName,
25+
pathParameters: {'type': ContentType.country.name, 'id': country.id},
3026
);
3127
},
3228
);

lib/headlines-search/widgets/source_item_widget.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
43
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
54
import 'package:go_router/go_router.dart';
65

@@ -22,12 +21,9 @@ class SourceItemWidget extends StatelessWidget {
2221
)
2322
: null,
2423
onTap: () {
25-
context.push(
26-
Routes.sourceDetails,
27-
extra: EntityDetailsPageArguments(
28-
entityId: source.id,
29-
contentType: ContentType.source,
30-
),
24+
context.pushNamed(
25+
Routes.entityDetailsName,
26+
pathParameters: {'type': ContentType.source.name, 'id': source.id},
3127
);
3228
},
3329
);

lib/headlines-search/widgets/topic_item_widget.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_news_app_mobile_client_full_source_code/entity_details/view/entity_details_page.dart';
43
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
54
import 'package:go_router/go_router.dart';
65

@@ -22,12 +21,9 @@ class TopicItemWidget extends StatelessWidget {
2221
)
2322
: null,
2423
onTap: () {
25-
context.push(
26-
Routes.topicDetails,
27-
extra: EntityDetailsPageArguments(
28-
entityId: topic.id,
29-
contentType: ContentType.topic,
30-
),
24+
context.pushNamed(
25+
Routes.entityDetailsName,
26+
pathParameters: {'type': ContentType.topic.name, 'id': topic.id},
3127
);
3228
},
3329
);

0 commit comments

Comments
 (0)