Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Latest commit

 

History

History
40 lines (25 loc) · 661 Bytes

avoid-dynamic.md

File metadata and controls

40 lines (25 loc) · 661 Bytes

Avoid dynamic

Rule id {#rule-id}

avoid-dynamic

Severity {#severity}

Warning

Description {#description}

Warns when dynamic type is used as variable type in declaration, return type of a function, etc. Using dynamic is considered unsafe since it can easily result in runtime errors.

Note: using dynamic type for Map<> is considered fine since there is no better way to declare type of JSON payload.

Example {#example}

Bad:

dynamic x = 10; // LINT

// LINT
String concat(dynamic a, dynamic b) {
  return a + b;
}

Good:

int x = 10;

final x = 10;

String concat(String a, String b) {
  return a + b;
}