dart.dev

always_ declare_ return_ types

Declare method return types.

build

always_ put_ control_ body_ on_ new_ line

Separate the control structure expression from its statement.

build

always_ put_ required_ named_ parameters_ first

Put required named parameters first.

build

always_ require_ non_ null_ named_ parameters

Specify @required on named parameters without defaults.

error

always_ specify_ types

Specify type annotations.

build

always_ use_ package_ imports

Avoid relative imports for files in lib/.

build

annotate_ overrides

Annotate overridden members.

build thumb_up flutter

annotate_ redeclares

Annotate redeclared members.

science build

async_ return_ with_ no_ await

Return with no await.

build

avoid_ annotating_ with_ dynamic

Avoid annotating with dynamic when not required.

build

avoid_ as

Avoid using as.

error

avoid_ bool_ literals_ in_ conditional_ expressions

Avoid bool literals in conditional expressions.

build

avoid_ catches_ without_ on_ clauses

Avoid catches without on clauses.

avoid_ catching_ errors

Don't explicitly catch Error or types that implement it.

avoid_ classes_ with_ only_ static_ members

Avoid defining a class that contains only static members.

avoid_ double_ and_ int_ checks

Avoid double and int checks.

avoid_ dynamic_ calls

Avoid method calls or property accesses on a dynamic target.

avoid_ empty_ else

Avoid empty statements in else clauses.

build circles thumb_up flutter

avoid_ equals_ and_ hash_ code_ on_ mutable_ classes

Avoid overloading operator == and hashCode on classes not marked @immutable.

avoid_ escaping_ inner_ quotes

Avoid escaping inner quotes by converting surrounding quotes.

build

avoid_ field_ initializers_ in_ const_ classes

Avoid field initializers in const classes.

avoid_ final_ parameters

Avoid final for parameter declarations.

build

avoid_ function_ literals_ in_ foreach_ calls

Avoid using forEach with a function literal.

build thumb_up flutter

avoid_ futureor_ void

Avoid using 'FutureOr ' as the type of a result.

science

avoid_ implementing_ value_ types

Don't implement classes that override ==.

avoid_ init_ to_ null

Don't explicitly initialize variables to null.

build thumb_up flutter

avoid_ js_ rounded_ ints

Avoid JavaScript rounded ints.

avoid_ multiple_ declarations_ per_ line

Don't declare multiple variables on a single line.

build

avoid_ null_ checks_ in_ equality_ operators

Don't check for null in custom == operators.

report build

avoid_ positional_ boolean_ parameters

Avoid positional boolean parameters.

avoid_ print

Avoid print calls in production code.

build flutter

avoid_ private_ typedef_ functions

Avoid private typedef functions.

report build

avoid_ redundant_ argument_ values

Avoid redundant argument values.

build

avoid_ relative_ lib_ imports

Avoid relative imports for files in lib/.

build circles thumb_up flutter

avoid_ renaming_ method_ parameters

Don't rename parameters of overridden methods.

build thumb_up flutter

avoid_ return_ types_ on_ setters

Avoid return types on setters.

build thumb_up flutter

avoid_ returning_ null

Avoid returning null from members whose return type is bool, double, int, or num.

error

avoid_ returning_ null_ for_ future

Avoid returning null for Future.

error

avoid_ returning_ null_ for_ void

Avoid returning null for void.

build thumb_up flutter

avoid_ returning_ this

Avoid returning this from methods just to enable a fluent interface.

avoid_ setters_ without_ getters

Avoid setters without getters.

avoid_ shadowing_ type_ parameters

Avoid shadowing type parameters.

circles thumb_up flutter

avoid_ single_ cascade_ in_ expression_ statements

Avoid single cascade in expression statements.

build thumb_up flutter

avoid_ slow_ async_ io

Avoid slow asynchronous dart:io methods.

avoid_ type_ to_ string

Avoid .toString() in production code since results may be minified.

avoid_ types_ as_ parameter_ names

Avoid types as parameter names.

circles thumb_up flutter

avoid_ types_ on_ closure_ parameters

Avoid annotating types for function expression parameters.

build

avoid_ unnecessary_ containers

Avoid unnecessary containers.

build flutter

avoid_ unstable_ final_ fields

Avoid overriding a final field to return different values if called multiple times.

error

avoid_ unused_ constructor_ parameters

Avoid defining unused parameters in constructors.

build

avoid_ void_ async

Avoid async functions that return void.

build

avoid_ web_ libraries_ in_ flutter

Avoid using web-only libraries outside Flutter web plugin packages.

flutter

await_ only_ futures

Await only futures.

build circles thumb_up flutter

camel_ case_ extensions

Name extensions using UpperCamelCase.

circles thumb_up flutter

camel_ case_ types

Name types using UpperCamelCase.

circles thumb_up flutter

cancel_ subscriptions

Cancel instances of dart:async StreamSubscription.

cascade_ invocations

Cascade consecutive method invocations on the same reference.

build

cast_ nullable_ to_ non_ nullable

Don't cast a nullable value to a non nullable type.

build

close_ sinks

Close instances of dart:core Sink.

combinators_ ordering

Sort combinator names alphabetically.

build

conditional_ uri_ does_ not_ exist

Missing conditional import.

constant_ identifier_ names

Prefer using lowerCamelCase for constant names.

build thumb_up flutter

control_ flow_ in_ finally

Avoid control flow in finally blocks.

thumb_up flutter

curly_ braces_ in_ flow_ control_ structures

DO use curly braces for all flow control structures.

build circles thumb_up flutter

depend_ on_ referenced_ packages

Depend on referenced packages.

circles thumb_up flutter

deprecated_ consistency

Missing deprecated annotation.

deprecated_ member_ use_ from_ same_ package

Avoid using deprecated elements from within the package in which they are declared.

build

diagnostic_ describe_ all_ properties

DO reference all public properties in debug methods.

build

directives_ ordering

Adhere to Effective Dart Guide directives sorting conventions.

build

discarded_ futures

There should be no Future-returning calls in synchronous functions unless they are assigned or returned.

build

do_ not_ use_ environment

Do not use environment declared variables.

document_ ignores

Document ignore comments.

empty_ catches

Avoid empty catch blocks.

build circles thumb_up flutter

empty_ constructor_ bodies

Use ; instead of {} for empty constructor bodies.

build thumb_up flutter

empty_ container_ bodies

Use ; instead of {} for empty container bodies.

build

empty_ statements

Avoid empty statements.

build thumb_up flutter

enable_ null_ safety

Do use sound null safety.

error

eol_ at_ end_ of_ file

Put a single newline at end of file.

build

exhaustive_ cases

Define case clauses for all constants in enum-like classes.

build thumb_up flutter

file_ names

Name source files using lowercase_with_underscores.

circles thumb_up flutter

flutter_ style_ todos

Use Flutter TODO format: // TODO(username): message, https://URL-to-issue.

build

future_ sync_ value

For synchronous values, Future.syncValue is more performant.

build

hash_ and_ equals

Always override hashCode if overriding ==.

build circles thumb_up flutter

implementation_ imports

Don't import implementation files from another package.

thumb_up flutter

implicit_ call_ tearoffs

Explicitly tear-off call methods when using an object as a Function.

build circles thumb_up flutter

implicit_ reopen

Don't implicitly reopen classes.

science build

initialize_ in_ field_ declaration

Initialize the field in the field's initializer.

build

invalid_ case_ patterns

Use case expressions that are valid in Dart 3.0.

science build

invalid_ runtime_ check_ with_ js_ interop_ types

Avoid runtime type tests with JS interop types where the result may not be platform-consistent.

thumb_up flutter

invariant_ booleans

Conditions should not unconditionally evaluate to true or to false.

error

join_ return_ with_ assignment

Join return statement with assignment when possible.

leading_ newlines_ in_ multiline_ strings

Start multiline strings with a newline.

build

library_ annotations

Attach library annotations to library directives.

build circles thumb_up flutter

library_ names

Name libraries using lowercase_with_underscores.

library_ prefixes

Use lowercase_with_underscores when specifying a library prefix.

thumb_up flutter

library_ private_ types_ in_ public_ api

Avoid using private types in public APIs.

thumb_up flutter

lines_ longer_ than_ 80_ chars

Avoid lines longer than 80 characters.

literal_ only_ boolean_ expressions

Boolean expression composed only with literals.

matching_ super_ parameters

Use matching super parameter names.

missing_ whitespace_ between_ adjacent_ strings

Missing whitespace between adjacent strings.

no_ adjacent_ strings_ in_ list

Don't use adjacent strings in list.

no_ default_ cases

No default cases.

science

no_ duplicate_ case_ values

Don't use more than one case with same value.

build circles thumb_up flutter

no_ dynamic_ casts

Avoid implicit casts from dynamic.

no_ leading_ underscores_ for_ library_ prefixes

Avoid leading underscores for library prefixes.

build thumb_up flutter

no_ leading_ underscores_ for_ local_ identifiers

Avoid leading underscores for local identifiers.

build thumb_up flutter

no_ literal_ bool_ comparisons

Don't compare boolean expressions to boolean literals.

build

no_ logic_ in_ create_ state

Don't put any logic in createState.

flutter

no_ raw_ types

Avoid raw types.

no_ runtimetype_ tostring

Avoid calling toString() on runtimeType.

no_ self_ assignments

Don't assign a variable to itself.

no_ wildcard_ variable_ uses

Don't use wildcard parameters or variables.

circles thumb_up flutter

non_ constant_ identifier_ names

Name non-constant identifiers using lowerCamelCase.

build circles thumb_up flutter

noop_ primitive_ operations

Noop primitive operations.

build

null_ check_ on_ nullable_ type_ parameter

Don't use null check on a potentially nullable type parameter.

build circles thumb_up flutter

null_ closures

Do not pass null as an argument where a closure is expected.

build thumb_up flutter

omit_ local_ variable_ types

Omit type annotations for local variables.

build

omit_ obvious_ local_ variable_ types

Omit obvious type annotations for local variables.

build

omit_ obvious_ property_ types

Omit obvious type annotations for top-level and static variables.

build

one_ member_ abstracts

Avoid defining a one-member abstract class when a simple function will do.

report

only_ throw_ errors

Only throw instances of classes extending either Exception or Error.

overridden_ fields

Don't override fields.

thumb_up flutter

package_ api_ docs

Provide doc comments for all public APIs.

error

package_ names

Use lowercase_with_underscores for package names.

thumb_up flutter

package_ prefixed_ library_ names

Prefix library names with the package name and a dot-separated path.

parameter_ assignments

Don't reassign references to parameters of functions or methods.

prefer_ adjacent_ string_ concatenation

Use adjacent strings to concatenate string literals.

build thumb_up flutter

prefer_ asserts_ in_ initializer_ lists

Prefer putting asserts in initializer lists.

prefer_ asserts_ with_ message

Prefer asserts with message.

prefer_ bool_ in_ asserts

Prefer using a boolean as the assert condition.

error

prefer_ collection_ literals

Use collection literals when possible.

build thumb_up flutter

prefer_ conditional_ assignment

Prefer using ??= over testing for null.

build thumb_up flutter

prefer_ const_ constructors

Prefer const with constant constructors.

build

prefer_ const_ constructors_ in_ immutables

Prefer declaring const constructors on @immutable classes.

build flutter

prefer_ const_ declarations

Prefer const over final for declarations.

build

prefer_ const_ literals_ to_ create_ immutables

Prefer const literals as parameters of constructors on @immutable classes.

build

prefer_ constructors_ over_ static_ methods

Prefer defining constructors instead of static methods to create instances.

prefer_ contains

Use contains for List and String instances.

build thumb_up flutter

prefer_ double_ quotes

Prefer double quotes where they won't require escape sequences.

build

prefer_ equal_ for_ default_ values

Use = to separate a named parameter from its default value.

error

prefer_ expression_ function_ bodies

Use => for short members whose body is a single return statement.

build

prefer_ final_ fields

Private field could be final.

build thumb_up flutter

prefer_ final_ in_ for_ each

Prefer final in for-each loop variable if reference is not reassigned.

build

prefer_ final_ locals

Prefer final for variable declarations if they are not reassigned.

build

prefer_ final_ parameters

Prefer final for parameter declarations if they are not reassigned.

report build

prefer_ for_ elements_ to_ map_ fromiterable

Prefer for elements when building maps from iterables.

build thumb_up flutter

prefer_ foreach

Use forEach to only apply a function to all the elements.

build

prefer_ function_ declarations_ over_ variables

Use a function declaration to bind a function to a name.

build thumb_up flutter

prefer_ generic_ function_ type_ aliases

Prefer generic function type aliases.

build circles thumb_up flutter

prefer_ if_ elements_ to_ conditional_ expressions

Prefer if elements to conditional expressions where possible.

build

prefer_ if_ null_ operators

Prefer using ?? operators.

build thumb_up flutter

prefer_ initializing_ formals

Use initializing formals when possible.

build thumb_up flutter

prefer_ inlined_ adds

Inline list item declarations where possible.

build thumb_up flutter

prefer_ int_ literals

Prefer int literals over double literals.

build

prefer_ interpolation_ to_ compose_ strings

Use interpolation to compose strings and values.

build thumb_up flutter

prefer_ is_ empty

Use isEmpty for Iterables and Maps.

build circles thumb_up flutter

prefer_ is_ not_ empty

Use isNotEmpty for Iterables and Maps.

build circles thumb_up flutter

prefer_ is_ not_ operator

Prefer is! operator.

build thumb_up flutter

prefer_ iterable_ wheretype

Prefer to use whereType on iterable.

build circles thumb_up flutter

prefer_ mixin

Prefer using mixins.

prefer_ null_ aware_ method_ calls

Prefer null-aware method calls.

prefer_ null_ aware_ operators

Prefer using null-aware operators.

build thumb_up flutter

prefer_ relative_ imports

Prefer relative imports for files in lib/.

build

prefer_ single_ quotes

Only use double quotes for strings containing single quotes.

build

prefer_ spread_ collections

Use spread collections when possible.

build thumb_up flutter

prefer_ typing_ uninitialized_ variables

Prefer typing uninitialized variables and fields.

build circles thumb_up flutter

prefer_ void_ to_ null

Don't use the Null type, unless you are positive that you don't want void.

build

provide_ deprecation_ message

Provide a deprecation message, via @Deprecated("message").

circles thumb_up flutter

public_ member_ api_ docs

Document all public members.

recursive_ getters

Property getter recursively returns itself.

thumb_up flutter

remove_ deprecations_ in_ breaking_ versions

Deprecation in major version.

require_ trailing_ commas

Use trailing commas for all parameter lists and argument lists.

build

secure_ pubspec_ urls

Use secure urls in pubspec.yaml.

circles thumb_up flutter

simple_ directive_ paths

Use simple directive paths.

build

simplify_ variable_ pattern

Avoid unnecessary member names in variable patterns.

build

sized_ box_ for_ whitespace

SizedBox for whitespace.

build flutter

sized_ box_ shrink_ expand

Use SizedBox shrink and expand named constructors.

sort_ child_ properties_ last

Sort child properties last in widget instance creations.

build flutter

sort_ constructors_ first

Sort constructor declarations before other members.

build

sort_ pub_ dependencies

Sort pub dependencies alphabetically.

build

sort_ unnamed_ constructors_ first

Sort unnamed constructor declarations first.

build

specify_ nonobvious_ local_ variable_ types

Specify non-obvious type annotations for local variables.

build

specify_ nonobvious_ property_ types

Specify non-obvious type annotations for top-level and static variables.

build

strict_ top_ level_ inference

Specify type annotations.

build circles thumb_up flutter

super_ goes_ last

Place the super call last in a constructor initialization list.

error

switch_ on_ type

Avoid switch statements on a 'Type'.

test_ types_ in_ equals

Test type of argument in operator ==(Object other).

throw_ in_ finally

Avoid throw in finally block.

tighten_ type_ of_ initializing_ formals

Tighten type of initializing formal.

type_ annotate_ public_ apis

Type annotate public APIs.

build

type_ init_ formals

Don't type annotate initializing formals.

build thumb_up flutter

type_ literal_ in_ constant_ pattern

Don't use constant patterns with type literals.

build circles thumb_up flutter

unawaited_ futures

Future results in async function bodies must be awaited or marked unawaited using dart:async.

build

unnecessary_ async

No await no async.

science build

unnecessary_ await_ in_ return

Unnecessary await keyword in return.

report build

unnecessary_ brace_ in_ string_ interps

Avoid using braces in interpolation when not needed.

build thumb_up flutter

unnecessary_ breaks

Don't use explicit breaks when a break is implied.

build

unnecessary_ const

Avoid const keyword.

build thumb_up flutter

unnecessary_ const_ in_ enum_ constructor

Don't use an explicit const in a generative enum constructor.

build

unnecessary_ constructor_ name

Unnecessary .new constructor name.

build thumb_up flutter

unnecessary_ final

Don't use final for local variables.

build

unnecessary_ getters_ setters

Avoid wrapping fields in getters and setters just to be "safe".

build thumb_up flutter

unnecessary_ ignore

Don't ignore a diagnostic code that is not produced.

build

unnecessary_ lambdas

Don't create a lambda when a tear-off will do.

build

unnecessary_ late

Don't specify the late modifier when it is not needed.

build thumb_up flutter

unnecessary_ library_ directive

Avoid library directives unless they have documentation comments or annotations.

build

unnecessary_ library_ name

Don't have a library name in a library declaration.

build thumb_up flutter

unnecessary_ new

Unnecessary new keyword.

build thumb_up flutter

unnecessary_ null_ aware_ assignments

Avoid null in null-aware assignment.

build thumb_up flutter

unnecessary_ null_ aware_ operator_ on_ extension_ on_ nullable

Unnecessary null aware operator on extension on a nullable type.

build

unnecessary_ null_ checks

Unnecessary null checks.

build

unnecessary_ null_ in_ if_ null_ operators

Avoid using null in ?? operators.

build thumb_up flutter

unnecessary_ nullable_ for_ final_ variable_ declarations

Use a non-nullable type for a final variable initialized with a non-nullable value.

build thumb_up flutter

unnecessary_ overrides

Don't override a method to do a super method invocation with the same parameters.

build circles thumb_up flutter

unnecessary_ parenthesis

Unnecessary parentheses can be removed.

build

unnecessary_ primary_ constructor_ body

Unnecessary primary constructor bodies can be removed.

build

unnecessary_ raw_ strings

Unnecessary raw string.

build

unnecessary_ statements

Avoid using unnecessary statements.

unnecessary_ string_ escapes

Remove unnecessary backslashes in strings.

build thumb_up flutter

unnecessary_ string_ interpolations

Unnecessary string interpolation.

build thumb_up flutter

unnecessary_ this

Don't access members with this unless avoiding shadowing.

build thumb_up flutter

unnecessary_ this_ alias

Use 'this' directly instead of assigning it to a local variable.

science

unnecessary_ to_ list_ in_ spreads

Unnecessary toList() in spreads.

build thumb_up flutter

unnecessary_ type_ name_ in_ constructor

Don't use an explicit type name in a constructor.

build

unnecessary_ unawaited

Unnecessary use of 'unawaited'.

build

unnecessary_ underscores

Unnecessary underscores can be removed.

build thumb_up flutter

unreachable_ from_ main

Unreachable top-level members in executable libraries.

build

unsafe_ html

Avoid unsafe HTML APIs.

error

unsafe_ variance

Unsafe type: Has a type variable in a non-covariant position.

science

use_ build_ context_ synchronously

Do not use BuildContext across asynchronous gaps.

flutter

use_ colored_ box

Use ColoredBox.

build

use_ declaring_ parameters

Use a declaring parameter.

build

use_ decorated_ box

Use DecoratedBox.

build

use_ enums

Use enums rather than classes that behave like enums.

build

use_ full_ hex_ values_ for_ flutter_ colors

Prefer an 8-digit hexadecimal integer (for example, 0xFFFFFFFF) to instantiate a Color.

build flutter

use_ function_ type_ syntax_ for_ parameters

Use generic function type syntax for parameters.

build thumb_up flutter

use_ if_ null_ to_ convert_ nulls_ to_ bools

Use ?? operators to convert nulls to bools.

report build

use_ is_ even_ rather_ than_ modulo

Prefer intValue.isOdd/isEven instead of checking the result of % 2.

use_ late_ for_ private_ fields_ and_ variables

Use late for private members with a non-nullable type.

science

use_ named_ constants

Use predefined named constants.

build

use_ null_ aware_ elements

If-elements testing for null can be replaced with null-aware elements.

build thumb_up flutter

use_ raw_ strings

Use raw string to avoid escapes.

build

use_ rethrow_ when_ possible

Use rethrow to rethrow a caught exception.

build thumb_up flutter

use_ setters_ to_ change_ properties

Use a setter for operations that conceptually change a property.

use_ string_ buffers

Use string buffers to compose strings.

use_ string_ in_ part_ of_ directives

Use string in part of directives.

build circles thumb_up flutter

use_ super_ parameters

Use super-initializer parameters where possible.

science build thumb_up flutter

use_ test_ throws_ matchers

Use throwsA matcher instead of fail().

use_ to_ and_ as_ if_ applicable

Start the name of the method with to/_to or as/_as if applicable.

use_ truncating_ division

Use truncating division.

build

valid_ regexps

Use valid regular expression syntax.

circles thumb_up flutter

var_ with_ no_ type_ annotation

Avoid declaring parameters with var and no type annotation.

science build

void_ checks

Don't assign to void.

circles thumb_up flutter

Read the original on dart.dev ↗