avoid_annotating_with_dynamic
Avoid annotating with dynamic when not required.
This rule is available as of Dart 2.0.
This rule has a quick fix available.
Details
#AVOID annotating with dynamic when not required.
As dynamic is the assumed return value of a function or method, it is usually not necessary to annotate it.
BAD:
dynamic lookUpOrDefault(String name, Map map, dynamic defaultValue) {
var value = map[name];
if (value != null) return value;
return defaultValue;
}GOOD:
lookUpOrDefault(String name, Map map, defaultValue) {
var value = map[name];
if (value != null) return value;
return defaultValue;
}Usage
#To enable the avoid_annotating_with_dynamic rule, add avoid_annotating_with_dynamic under linter > rules in your analysis_options.yaml file:
linter:
rules:
- avoid_annotating_with_dynamicUnless stated otherwise, the documentation on this site reflects Dart 3.6.0. Page last updated on 2024-07-03. View source or report an issue.