Skip to content

Files

Latest commit

 

History

History
43 lines (29 loc) · 743 Bytes

unnecessary_late.md

File metadata and controls

43 lines (29 loc) · 743 Bytes

Pattern: Unnecessary late modifier

Issue: -

Description

DO not specify the late modifier for top-level and static variables when the declaration contains an initializer.

Top-level and static variables with initializers are already evaluated lazily as if they are marked late.

Example of incorrect code:

late String badTopLevel = '';

Example of correct code:

String goodTopLevel = '';

Example of incorrect code:

class BadExample {
 static late String badStatic = '';
}

Example of correct code:

class GoodExample {
 late String goodStatic;
}

Further Reading