unnecessary_ nullable_ for_ final_ variable_ declarations
Use a non-nullable type for a final variable initialized with a non-nullable value.
Details
#Use a non-nullable type for a final variable initialized with a non-nullable value.
BAD:
final int? i = 1;
GOOD:
final int i = 1;
Enable
#
To enable the
unnecessary_nullable_for_final_variable_declarations
rule, add
unnecessary_nullable_for_final_variable_declarations
under
linter > rules
in your
analysis_options.yaml
file:
linter:
rules:
- unnecessary_nullable_for_final_variable_declarations
If you're instead using the YAML map syntax to configure linter rules,
add
unnecessary_nullable_for_final_variable_declarations: true
under
linter > rules:
linter:
rules:
unnecessary_nullable_for_final_variable_declarations: true
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Report an issue.