Skip to content

Lints to be considered for score.yaml or recommend.yaml from Flutter #58349

@goderbauer

Description

@goderbauer

The following lints are no-ops for non-Flutter code and adding them to the general lint set shouldn't cause any harm. They help developers craft clean UI code without unnecessary cruft while honoring the widget lifecycle contract and encourage good widget design practices.

  • avoid_unnecessary_containers
  • avoid_web_libraries_in_flutter
  • no_logic_in_create_state
  • sized_box_for_whitespace
  • use_full_hex_values_for_flutter_colors
  • use_key_in_widget_constructors

The following lints also affect non-Flutter code, but I hope they can be added to the general lint set as well to have alignment between regular Dart and Flutter code (if not, they should go into a Flutter-specific lint set). Encouraging the use of const Widgets is beneficial for performance.

  • prefer_const_constructors
  • prefer_const_constructors_in_immutables
  • prefer_const_declarations
  • prefer_const_literals_to_create_immutables
  • avoid_type_to_string (currently broken: Rule avoid_type_to_string not working #58377) - avoids hard to debug differences between debug and release mode
  • no_runtimeType_toString (subset of avoid_type_to_string? If yes, not needed.) - discourages performance pitfall
  • prefer_if_elements_to_conditional_expressions - cleaner code when generating children lists

The following lint is not appropriate for non-Flutter apps and should go into a Flutter-specific lint set:

  • avoid_print - avoids polluting production logs

@mit-mit and/or @munificent to figure out if the first two lists in this bug are OK to add to the general lint set.

/cc @Hixie @pq @devoncarew

Metadata

Metadata

Assignees

Labels

devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions