always_put_control_body_on_new_line
Statement should be on a separate line.
Description
#The analyzer produces this diagnostic when the code being controlled by a control flow statement (if
, for
, while
, or do
) is on the same line as the control flow statement.
Example
#The following code produces this diagnostic because the return
statement is on the same line as the if
that controls whether the return
will be executed:
dart
void f(bool b) {
if (b) return;
}
Common fixes
#Put the controlled statement onto a separate, indented, line:
dart
void f(bool b) {
if (b)
return;
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.