flutter-styleguide
flutter-styleguide copied to clipboard
Unused parameters in a method should be replaced with an underscore
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(),
}
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.