no_ raw_ types
Learn about the no_raw_types linter rule.
Avoid raw types.
Details
#DON'T use raw types.
A raw type is a type annotation for a generic type which omits type arguments. Developers may mistakenly believe that the type arguments are inferred, but in fact each type parameter's bound is used, which can lead to lost type information.
BAD:
List list = [1, 2, 3];
GOOD:
List<int> list = [1, 2, 3];
Enable
#
To enable the no_raw_types rule, add no_raw_types under
linter > rules in your analysis_options.yaml
file:
linter:
rules:
- no_raw_types
If you're instead using the YAML map syntax to configure linter rules,
add no_raw_types: true under linter > rules:
linter:
rules:
no_raw_types: true
Unless stated otherwise, the documentation on this site reflects Dart 3.12.2. Report an issue.