-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Turning if chains into shorter switch statements
#144977
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
Turning if chains into shorter switch statements
#144977
Conversation
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a tiny formatting nit
| setState(() { | ||
| _animationDirection = status; | ||
| }); | ||
| setState(() => _animationDirection = status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, we prefer styling setState as a block like it was before. Can you revert this formatting change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look through the repo and you're right—an overwhelming majority of setState calls use a function body even if there's just one statement.
I was surprised at how many were formatted as a single line without the => syntax:
setState(() { _value = newValue; });I guess now I know to use curly braces in the Flutter repo from now on.
loic-sharma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the excellent contribution!
This pull request is part of the effort to solve issue #144903.
In the past, my efforts to reduce line length involved refactoring away from switch statements, but unlike yesterday's PR, this one is full of switch statements that make things more concise!