unnecessary_late
Unnecessary 'late' modifier.
Description
#The analyzer produces this diagnostic when a top-level variable or static field with an initializer is marked as late
. Top-level variables and static fields are implicitly late, so they don't need to be explicitly marked.
Example
#The following code produces this diagnostic because the static field c
has the modifier late
even though it has an initializer:
dart
class C {
static late String c = '';
}
Common fixes
#Remove the keyword late
:
dart
class C {
static String c = '';
}
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.