Skip to content

Files

Latest commit

 

History

History
30 lines (23 loc) · 685 Bytes

avoid_annotating_with_dynamic.md

File metadata and controls

30 lines (23 loc) · 685 Bytes

Pattern: Annotating with dynamic

Issue: -

Description

As dynamic is the assumed return value of a function or method, it is usually not necessary to annotate it.

Example of incorrect code:

dynamic lookUpOrDefault(String name, Map map, dynamic defaultValue) {
 var value = map[name];
 if (value != null) return value;
 return defaultValue;
}

Example of correct code:

lookUpOrDefault(String name, Map map, defaultValue) {
 var value = map[name];
 if (value != null) return value;
 return defaultValue;
}

Further Reading