newline-before-constructor
- Group
- Style
- Path
lint/style/newline-before-constructor- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 275 of 512
Requires a blank line before constructors following another member.
Includes named, redirecting, and factory constructor declarations. The first member is exempt unless enum constants precede it; constructor invocations are not checked. Blank lines above attached comments count.
Invalid
class Example {
final int value;
Example(this.value);
Example.zero() : value = 0;
Example.one() : value = 1;
}
class FactoryExample {
FactoryExample();
factory FactoryExample.create() => FactoryExample();
}
class Nested {
void method() {
final value = Example(1);
print(value);
}
Nested();
}
enum Action {
run;
const Action();
}
class Documented {
final int value;
/// No blank line above this documentation.
Documented(this.value);
} final int value; Example(this.value); Example(this.value); Example.zero() : value = 0; FactoryExample(); factory FactoryExample.create() => FactoryExample(); } Nested(); run; const Action(); /// No blank line above this documentation. Documented(this.value);Valid
class Example {
Example();
Example.named();
factory Example.create() => Example();
}
class FirstConstructor {
FirstConstructor() {
final make = () { return Example(); };
make();
}
}
class Fields {
final int value;
const Fields(this.value);
}
class Documented {
final int value;
/// Creates a documented instance.
Documented(this.value);
}
enum Action {
run;
/// Creates an action.
const Action();
}Configure newline-before-constructor
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"newline-before-constructor": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/newline-before-constructor: <reason>More style rules
- newline-before-continue
Requires a blank line before a continue that follows another statement.
- newline-before-method
Requires a blank line before method declarations following another member.
- newline-before-return
newline-before-returnFlags
returnstatements that are not preceded by a blank line. - newline-before-throw
Requires a blank line before a throw that follows another statement.
- no-default-cases
no_default_casesFlags
default:in switch statements over enums and enum-like classes. - no-leading-underscores-for-library-prefixes
no_leading_underscores_for_library_prefixesrecommendedFlags import prefixes that begin with an underscore.
- no-leading-underscores-for-local-identifiers
no_leading_underscores_for_local_identifiersrecommendedFlags local variables and parameters whose names begin with an underscore.
- no-literal-bool-comparisons
no_literal_bool_comparisonsFlags boolean literals compared or combined with a non-nullable
bool.