Skip to content

Linter features for Flutter code #57238

Open
@Hixie

Description

@Hixie

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. in if statements) unless there's a chain (with else) and one of the elements in the chain has a multi-line block. we've decided to be lax about this
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-requesttype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions