Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add go router package and routing to the app #1401

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SofiaRey
Copy link
Contributor

@SofiaRey SofiaRey commented Dec 20, 2024

Description

Routing refactored now using go_router package.

TO DO:

  • Check tests related to category_feed.dart and article_content.dart (many are breaking due to change of implementation of NetworkErrorPage navigation and the 'Retry' function now being called after the page is pushed)
  • Check PR comments
Demo videos

Profile, Notification preferences and Subscriptions page:

1.mov

Article page, slideshow and Subscriptions page:

2.mov

Login flow

4.mov

Article details

3.mov

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@SofiaRey SofiaRey requested a review from matiasleyba December 20, 2024 18:37
@SofiaRey SofiaRey self-assigned this Dec 20, 2024
@SofiaRey SofiaRey marked this pull request as ready for review January 6, 2025 17:59
import 'package:flutter_news_example/home/home.dart';
import 'package:flutter_news_example/login/login.dart';
import 'package:flutter_news_example/magic_link_prompt/view/magic_link_prompt_page.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to be able to use barrel files instead of importing the file directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check other imports too

final id = state.pathParameters['id'];

final isVideoArticle = bool.tryParse(
state.uri.queryParameters['isVideoArticle'] ?? 'false',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.uri.queryParameters can be abstracted as a variable to reuse

: null;

if (id == null) {
throw Exception('Missing required "id" parameter');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's shown when this happens ? Isn't better to render NetworkError instead?

@@ -31,6 +33,17 @@ class HomeView extends StatelessWidget {
}
},
),
BlocListener<AppBloc, AppState>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlocListener<CardActivationCubit, CardActivationState>(
  listenWhen: (_, current) => current  == AppStatus.onboardingRequired , 
  listener: (context, _) => context.goNamed(OnboardingPage.routePath),
),

Something like this could be simpler, what do you think?

@@ -40,7 +45,7 @@ void main() {

testWidgets('renders FeedView', (tester) async {
await tester.pumpApp(
const HomePage(),
InheritedGoRouter(goRouter: router, child: const HomePage()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is InheritedGoRouter necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should remove these tests, but adapt them to the new approach to navigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants