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

chore: go router proposal #216

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

chore: go router proposal #216

wants to merge 2 commits into from

Conversation

f7deleon
Copy link
Member

♻️ Refactor

✏️ Description:

Proposal to remove auto router since it uses the build runner package and makes you regenerate the code each time you change the navigation tree.

@f7deleon f7deleon force-pushed the feat/propose-go-router branch 3 times, most recently from 93d8e29 to 857c85d Compare August 26, 2024 18:18
Copy link
Contributor

@fedecor9 fedecor9 left a comment

Choose a reason for hiding this comment

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

Nice

],
redirect: (BuildContext context, GoRouterState state) {
final authState = AuthenticationScope.of(context);
if (authState == AuthenticationStatus.unauthenticated) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to be careful, if this is evaluated at the top of the navigation tree, a new route /details it will be redirected to / because it returns a modified value for the path.
Maybe we should return null if the user is authenticated or check the current path and redirect based on that.
We had this problem in another project that used go_router

),
];
}
final GoRouter appRouter = GoRouter(
Copy link
Contributor

Choose a reason for hiding this comment

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

It can be good to add the initial route as a parameter for testing and deep linking, what do you think?

routes: <RouteBase>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add a helper method for creating the page widget

GoRoute(
path: '/welcome',
builder: (BuildContext context, GoRouterState state) =>
const WelcomeScreen(),
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if we want to send parameters to the page without going to a repository, for example a details page. Do we have an example on how that would look?

Copy link
Collaborator

@mirland mirland left a comment

Choose a reason for hiding this comment

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

I think we should check what happen with args

@@ -69,7 +68,7 @@ class _ProjectWidget extends StatelessWidget {

@override
Widget build(BuildContext context) => GestureDetector(
onTap: () => FlutterWebBrowser.openWebPage(url: project.url),
onTap: () => context.push('/details'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't be constant?

final SessionRepository _sessionRepository;
final AuthenticationStatus _requiredAppStatus;
final PageRouteInfo _redirectPage;
class AuthenticationScope extends InheritedNotifier<StreamAuthNotifier> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

cannot we avoid it? I'ts strange to use a InheritedNotifier. We should use a provider or something like that, we shouldn't mix how we get data

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.

3 participants