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

How to customize route name? #14

Closed
rebaz94 opened this issue Jan 13, 2020 · 7 comments
Closed

How to customize route name? #14

rebaz94 opened this issue Jan 13, 2020 · 7 comments

Comments

@rebaz94
Copy link

rebaz94 commented Jan 13, 2020

Thanks for this awesome package.
Is there is anyway to customize route name instead of default variable name?

@Milad-Akarie
Copy link
Owner

Hey @rebaz94. I'm not sure I understand your question.
You can actually name your route anything you want.
HomeScreen myWhateverHomeScreenRouteName;

@kuhnroyal
Copy link
Contributor

I also think there should be an optional way to name routes via the annotations.

@MaterialRoute(name = `/foo/bar`)
MyFancyRoute foo;

@Milad-Akarie
Copy link
Owner

Milad-Akarie commented Jan 13, 2020

Hey @kuhnroyal, can you explain where is that useful?
I'm generally aiming for less boilerplate code.
I'm planning to add a global optional prefix/suffix, would that satisfy what you have in mind?

@AutoRouter(namePrefix: 'myPrefix', nameSuffix: 'mySuffix')
class $MyRouter{}

@kuhnroyal
Copy link
Contributor

I am think about flutter web and readable URL like route names.

@rebaz94
Copy link
Author

rebaz94 commented Jan 13, 2020

@Milad-Akarie Yes I know this way, but there should be an option to set custom name.
For example if I want to set route name to be /edit-screen thats not possible now because we can't do EditScreen edit-screen, and as @kuhnroyal suggested for readability name of web routes

@Milad-Akarie
Copy link
Owner

Milad-Akarie commented Jan 13, 2020

@kuhnroyal @rebaz94 until now I didn't consider flutter web as I haven't had the chance to temper with it yet. So thanks for bringing that to my attention.

so the idea I have in mind right now is to first make auto-generated route names URL-friendly (kabab cased) by default and also add an optional route name in all route annotations as @kuhnroyal suggested.
@MaterialRoute(name: 'my-route-name')

Thank you both for taking the time to help make auto_route better.

@Milad-Akarie
Copy link
Owner

Milad-Akarie commented Jan 18, 2020

@rebaz94 @kuhnroyal
added in v0.2.2
Auto-generated route names are now url-friendly
homePage => '/home-page'

you can also pass custom names for all route types as follows
@MaterialRoute(name: 'your-custom-path-name')
Thanks for your time.

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

No branches or pull requests

3 participants