Open
Description
Flutter adds to the Dart style guide with:
https://github.com/flutter/engine/blob/master/sky/specs/style-guide.md
Many things in that list could be caught by a linter (or a code reformatter), such as:
- Never use
var
. - Always type everything explicitly except arguments named
_
,__
,___
, etc. - Don't use
_
arguments. - Never use
as
. - Constructors always come first.
- Default (unnamed) constructor should come first among the constructors.
- Whitespace inside
{}
,[]
,()
blocks should be symmetric at the start and end. (i.e. If a block starts with a newline, it ends with a newline. If it starts with two, it ends with two. If it starts with a space, it ends with a space. And so on.) - Don't call super if you have no arguments to pass up to the superclass.
- Always put the body of an
if
on its own line. -
Avoid braces around one-line code blocks (e.g. inwe've decided to be lax about thisif
statements) unless there's a chain (withelse
) and one of the elements in the chain has a multi-line block. - Use a switch when examining an enum, not an
if
chain or?:
operator. - Only use
=>
if both sides fit on the same line or if the expression is a single constructor call.