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

Unused parameters in a method should be replaced with an underscore #1

Open
rapPayne opened this issue Oct 22, 2019 · 1 comment
Open

Comments

@rapPayne
Copy link
Member

When providing a closure that accepts parameters for which you don't need to provide a value, it is recommended that you use the underscore/underbar character (_). For example, when creating routes in MaterialApp, you specify a context. Don't do this:

routes: {
  '/', (context) => SomeWidget(),
  '/route2': (context) => Widget2(),
}

Do:

routes: {
  '/', (_) => SomeWidget(),
  '/route2': (_) => Widget2(),
}
@aloisdeniel
Copy link

I dont like hiding the context object in particular. Several times, I refactored the body of the method and used the parent's context instead of the builder context because of its _ name.

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

2 participants