Dart Analyze

Dart Analyze

Community Analyzer
Avoid unnecessary containers DRT-W1072
Anti-pattern
Major

AVOID wrapping widgets in unnecessary containers. Wrapping a widget in Container with no other parameters set has no effect

Avoid final for parameter declarations DRT-W1054
Anti-pattern
Major

AVOID declaring parameters as final. Declaring parameters as final can lead to unnecessarily verbose code, especially

Sort combinator names alphabetically DRT-W1080
Anti-pattern
Major

DO sort combinator names alphabetically. BAD:

Sort pub dependencies alphabetically DRT-W1039
Anti-pattern
Major

DO sort pub dependencies alphabetically (A to Z) in pubspec.yaml. Sorting list of pub dependencies makes maintenance easier.

Avoid bool literals in conditional expressions DRT-W1046
Anti-pattern
Major

AVOID bool literals in conditional expressions. BAD:

Avoid shadowing type parameters DRT-W1069
Anti-pattern
Major

AVOID shadowing type parameters. BAD:

Prefer using lowerCamelCase for constant names DRT-W1082
Anti-pattern
Major

PREFER using lowerCamelCase for constant names. In new code, use lowerCamelCase for constant variables, including enum values.

Attach library doc comments to library directives DRT-W1084
Anti-pattern
Major

Attach library doc comments (with ///) to library directives, rather than leaving them dangling near the top of a library.

Put required named parameters first DRT-W1042
Anti-pattern
Major

DO specify required on named parameter before other named parameters. BAD:

Depend on referenced packages DRT-W1036
Anti-pattern
Major

DO depend on referenced packages. When importing a package, add a dependency on it to your pubspec.

Use secure urls in pubspec.yaml DRT-W1038
Anti-pattern
Major

DO Use secure urls in pubspec.yaml. Use https instead of http or git:.

Declare method return types DRT-W1040
Anti-pattern
Major

DO declare method return types. When declaring a method or function always specify a return type.

Annotate overridden members DRT-W1044
Anti-pattern
Major

DO annotate overridden methods and fields. This practice improves code readability and helps protect against

Avoid annotating with dynamic when not required DRT-W1045
Anti-pattern
Major

AVOID annotating with dynamic when not required. As dynamic is the assumed return value of a function or method, it is usually

Avoid field initializers in const classes DRT-W1053
Anti-pattern
Major

AVOID field initializers in const classes. Instead of final x = const expr;, you should write get x => const expr; and

Avoid catches without on clauses DRT-W1047
Anti-pattern
Major

AVOID catches without on clauses. Using catch clauses without on clauses make your code prone to encountering

Don't explicitly catch Error or types that implement it DRT-W1048
Anti-pattern
Major

DON'T explicitly catch Error or types that implement it. Errors differ from Exceptions in that Errors can be analyzed and prevented prior