avoid_dynamic
Severity | Quick Fix | Options |
---|---|---|
Info | ❌ | ❌ |
Details
DO avoid using the dynamic
type unnecessarily.
While the dynamic
type can be useful in certain scenarios, it sacrifices the benefits of static typing and decreases code readability.
Using
dynamic
with Map
will not trigger the lint.Bad
dynamic thing = 'text';
void log(dynamic something) => print(something);
List<dynamic> list = [1, 2, 3];
final setLiteral = <dynamic>{'a', 'b', 'c'};
Good
String thing = 'text';
void log(String something) => print(something);
List<int> list = [1, 2, 3];
final setLiteral = <String>{'a', 'b', 'c'};