In Project Set Up Do Not Forget Lints And Metrics
A more opinionated way to set up Flutter and Dart code analysis
One of the most important steps in Dart and Flutter App design is setting up static analysis in the form of lints and code metrics. While lints take care of code errors, one uses code metrics to make architecture decisions about which OOP patterns to use.
What Is The Dart Linter?
The Dart linter is a static analyzer for identifying problems in Dart and Flutter code. There now are over 300 lint rules, checking anything from type issues, coding style, and proper Flutter widget usage and formatting.
You can set up the Dart analyzer and linter to do it anyway you like. Some rules are more important than others, with some of them being for just style. While you can choose any lint rule or set of lint rules, the Dart and Flutter SDK teams have published an Effective Dart guide:
https://dart.dev/effective-dart/style
A large set of lint rules are based on those Effect Dart Style guidelines.
The whole reason why you want to specify lints and metrics at the start of the project is that a large code-base with no lints applied will take a long time to clean up once you start applying lint rules or a lint rule set to that code-base.
To study and read more about the lint rules, these two places:
https://dart.dev/tools/analysis
https://dart.dev/tools/linter-rules
The options for Dart Linter are set up in an analysis file, such as:
# This file configures the static analysis results for your project (errors, | |
# warnings, and lints). | |
# | |
# This enables the 'recommended' set of lints from `package:lints`. | |
# This set helps identify many issues that may lead to problems when running | |
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | |
# style and format. | |
# | |
# If you want a smaller set of lints you can change this to specify | |
# 'package:lints/core.yaml'. These are just the most critical lints | |
# (the recommended set includes the core lints). | |
# The core lints are also what is used by pub.dev for scoring packages. | |
include: package:lints/recommended.yaml | |
# Uncomment the following section to specify additional rules. | |
# linter: | |
# rules: | |
# - camel_case_types | |
# analyzer: | |
# exclude: | |
# - path/to/excluded/files/** | |
# For more information about the core and recommended set of lints, see | |
# https://dart.dev/go/core-lints | |
# For additional information about configuring this file, see | |
# https://dart.dev/guides/language/analysis-options |
And, it's divided up into these parts:
-include
-analyzer
-linter
Include Line
The include line can only point to one file.Usually, it's a group of lint and analyzer settings.
Analyzer Block
The Analyzer block includes an exclusion to exclude files and folders. The language block has these possible boolean settings:
- strict-casts
- strict-inference
- strict-raw-types
Now, let me show you the two set of lint rules I use.
Two Lint Rule Sets To Rule Them All
I use Passy's Lint package:
https://pub.dev/packages/lint
And I use the Dart Code Linter package which has both additiona lints and code metrics:
https://pub.dev/packages/dart_code_linter
NOTE: As of March 2024 version 1.1.2 is not working due to a dependency, you will want the 1.1.1 version.
The dev dependency imports in pubspec will be:
dev_dependencies: | |
lint: ^2.0.0 | |
dart_code_linter: ^1.1.1 | |
test: ^1.24.0 |
But, they then differ in how they are applied to the analysis options file. Passy's lint import is at the top of the analysis options file:
# This file configures the static analysis results for your project (errors, | |
# warnings, and lints). | |
# | |
# This enables the 'recommended' set of lints from `package:lints`. | |
# This set helps identify many issues that may lead to problems when running | |
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | |
# style and format. | |
# | |
# If you want a smaller set of lints you can change this to specify | |
# 'package:lints/core.yaml'. These are just the most critical lints | |
# (the recommended set includes the core lints). | |
# The core lints are also what is used by pub.dev for scoring packages. | |
# how to inclued the lint strict lint rule set | |
include: package:lint/strict.yaml | |
analyzer: | |
language: | |
# lint has only strict-casts marked true but VGV analytics | |
# has the rest | |
strict-inference: true | |
strict-raw-types: true | |
Then for Dart Code Linter lints and metrics one has to apply the plugin at the analyzer block:
# This file configures the static analysis results for your project (errors, | |
# warnings, and lints). | |
# | |
# This enables the 'recommended' set of lints from `package:lints`. | |
# This set helps identify many issues that may lead to problems when running | |
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | |
# style and format. | |
# | |
# If you want a smaller set of lints you can change this to specify | |
# 'package:lints/core.yaml'. These are just the most critical lints | |
# (the recommended set includes the core lints). | |
# The core lints are also what is used by pub.dev for scoring packages. | |
# how to inclued the lint strict lint rule set | |
include: package:lint/strict.yaml | |
analyzer: | |
language: | |
# lint has only strict-casts marked true but VGV analytics | |
# has the rest | |
strict-inference: true | |
strict-raw-types: true | |
# errors from VGV analytics minus what lint package has | |
errors: | |
close_sinks: ignore | |
record_literal_one_positional_no_trailing_comma: error | |
collection_methods_unrelated_type: warning | |
unrelated_type_equality_checks: warning | |
exclude: | |
#- '**.freezed.dart' | |
#- '**.g.dart' | |
plugins: | |
- dart_code_linter |
Then to apply the Dart Code Linter Lints and Metrics we have the Dart Code Linter block below that:
dart_code_linter: | |
# I do not use extends but have implemented my | |
# own extra lint rule list | |
anti-patterns: | |
- long-method | |
- long-parameter-list | |
metrics: | |
cyclomatic-complexity: 20 | |
halstead-volume: 150 | |
maintainability-index: 50 | |
maximum-nesting-level: 5 | |
number-of-parameters: 4 | |
number-of-methods: 10 | |
source-lines-of-code: 250 | |
technical-debt: | |
threshold: 1 | |
todo-cost: 161 | |
ignore-cost: 320 | |
ignore-for-file-cost: 396 | |
as-dynamic-cost: 322 | |
deprecated-annotations-cost: 37 | |
file-nullsafety-migration-cost: 41 | |
unit-type: "USD" | |
metrics-exclude: | |
- test/** | |
# full rules list is at | |
# https://dcl.apps.bancolombia.com/docs/rules/ | |
rules: | |
#dart | |
- avoid-substring | |
# used with sort_child_properties_last | |
- arguments-ordering: | |
child-last: true | |
# these are used to help enforce arch decisions | |
# - avoid-banned-imports | |
# - avoid-banned-types | |
- avoid-cascade-after-if-null | |
- avoid-collection-methods-with-unrelated-types | |
- avoid-duplicate-exports | |
- avoid-dynamic | |
- avoid-global-state | |
# - avoid-ignoring-return-values | |
# - avoid-late-keyword: | |
# allow-initialized: true | |
- avoid-missing-enum-constant-in-map | |
- avoid-nested-conditional-expressions | |
- avoid-non-ascii-symbols | |
# - avoid-non-null-assertion: | |
# skip-checked-fields: true | |
# - avoid-passing-async-when-sync-expected | |
# - avoid-redundant-async | |
- avoid-throw-in-catch-block | |
- avoid-top-level-members-in-tests | |
- avoid-unnecessary-type-assertions | |
- avoid-unnecessary-type-casts | |
- avoid-unrelated-type-assertions: | |
ignore-mixins: false | |
- avoid-unused-parameters: | |
ignore-inline-functions: false | |
# - ban-name | |
# - banned-usage | |
- binary-expression-operand-order | |
- double-literal-format | |
- format-comment: | |
only-doc-comments: true | |
ignored-patterns: | |
- ^ cSpell.* | |
# - match-class-name-pattern: | |
# entries: | |
# - path: '.*state.dart' | |
# pattern: 'State$' | |
# ignore-private: true | |
- missing-test-assertion: | |
include-assertions: | |
- verify | |
include-methods: | |
- customTest | |
- newline-before-return | |
- no-boolean-literal-compare: | |
allow-false: true | |
# - no-empty-block | |
- no-equal-arguments: | |
ignored-parameters: | |
- height | |
- width | |
- no-equal-then-else | |
# - no-magic-number: | |
# allowed: [3.14, 100, 12] | |
# allow-only-once: true | |
- no-object-declaration | |
- prefer-async-await | |
- prefer-commenting-analyzer-ignores | |
- prefer-conditional-expressions: | |
ignore-nested: true | |
# - prefer-correct-identifier-length: | |
# exceptions: [ 'a' ] | |
# max-identifier-length: 30 | |
# min-identifier-length: 4 | |
- prefer-correct-test-file-name | |
- prefer-correct-type-name: | |
excluded: [ 'exampleExclude' ] | |
min-length: 3 | |
max-length: 40 | |
- prefer-enums-by-name | |
- prefer-first | |
- prefer-immediate-return | |
- prefer-iterable-of | |
- prefer-last | |
- prefer-match-file-name | |
- prefer-moving-to-variable: | |
allowed-duplicated-chains: 3 | |
- prefer-static-class | |
- prefer-trailing-comma: | |
break-on: 2 | |
- avoid-double-slash-imports | |
- avoid-unnecessary-conditionals | |
# flutter | |
- prefer-define-hero-tag | |
- always-remove-listener | |
- avoid-border-all | |
- avoid-returning-widgets: | |
ignored-names: | |
- testFunction | |
ignored-annotations: | |
- allowedAnnotation | |
- avoid-shrink-wrap-in-lists | |
- avoid-expanded-as-spacer | |
- avoid-wrapping-in-padding | |
- check-for-equals-in-render-object-setters | |
- consistent-update-render-object | |
- prefer-const-border-radius | |
- prefer-correct-edge-insets-constructor | |
# - prefer-extracting-callbacks | |
- prefer-single-widget-per-file | |
- prefer-using-list-view | |
- use-setstate-synchronously | |
# Intl, uncomment when needed | |
# - prefer-intl-name | |
# - prefer-provide-intl-description | |
# - provide-correct-intl-args | |
- member-ordering: | |
order: | |
- constructors | |
- public-fields | |
- private-fields | |
- close-method | |
- dispose-method | |
widgets-order: | |
- constructor | |
- build-method | |
- init-state-method | |
- did-change-dependencies-method | |
- did-update-widget-method | |
- dispose-method | |
linter: | |
rules: | |
And the whole file looks like this:
# warnings, and lints). | |
# | |
# This enables the 'recommended' set of lints from `package:lints`. | |
# This set helps identify many issues that may lead to problems when running | |
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | |
# style and format. | |
# | |
# If you want a smaller set of lints you can change this to specify | |
# 'package:lints/core.yaml'. These are just the most critical lints | |
# (the recommended set includes the core lints). | |
# The core lints are also what is used by pub.dev for scoring packages. | |
# how to inclued the lint strict lint rule set | |
include: package:lint/strict.yaml | |
analyzer: | |
language: | |
# lint has only strict-casts marked true but VGV analytics | |
# has the rest | |
strict-inference: true | |
strict-raw-types: true | |
# errors from VGV analytics minus what lint package has | |
errors: | |
close_sinks: ignore | |
record_literal_one_positional_no_trailing_comma: error | |
collection_methods_unrelated_type: warning | |
unrelated_type_equality_checks: warning | |
exclude: | |
#- '**.freezed.dart' | |
#- '**.g.dart' | |
plugins: | |
- dart_code_linter | |
dart_code_linter: | |
# I do not use extends but have implemented my | |
# own extra lint rule list | |
anti-patterns: | |
- long-method | |
- long-parameter-list | |
metrics: | |
cyclomatic-complexity: 20 | |
halstead-volume: 150 | |
maintainability-index: 50 | |
maximum-nesting-level: 5 | |
number-of-parameters: 4 | |
number-of-methods: 10 | |
source-lines-of-code: 250 | |
technical-debt: | |
threshold: 1 | |
todo-cost: 161 | |
ignore-cost: 320 | |
ignore-for-file-cost: 396 | |
as-dynamic-cost: 322 | |
deprecated-annotations-cost: 37 | |
file-nullsafety-migration-cost: 41 | |
unit-type: "USD" | |
metrics-exclude: | |
- test/** | |
# full rules list is at | |
# https://dcl.apps.bancolombia.com/docs/rules/ | |
rules: | |
#dart | |
- avoid-substring | |
# used with sort_child_properties_last | |
- arguments-ordering: | |
child-last: true | |
# these are used to help enforce arch decisions | |
# - avoid-banned-imports | |
# - avoid-banned-types | |
- avoid-cascade-after-if-null | |
- avoid-collection-methods-with-unrelated-types | |
- avoid-duplicate-exports | |
- avoid-dynamic | |
- avoid-global-state | |
# - avoid-ignoring-return-values | |
# - avoid-late-keyword: | |
# allow-initialized: true | |
- avoid-missing-enum-constant-in-map | |
- avoid-nested-conditional-expressions | |
- avoid-non-ascii-symbols | |
# - avoid-non-null-assertion: | |
# skip-checked-fields: true | |
# - avoid-passing-async-when-sync-expected | |
# - avoid-redundant-async | |
- avoid-throw-in-catch-block | |
- avoid-top-level-members-in-tests | |
- avoid-unnecessary-type-assertions | |
- avoid-unnecessary-type-casts | |
- avoid-unrelated-type-assertions: | |
ignore-mixins: false | |
- avoid-unused-parameters: | |
ignore-inline-functions: false | |
# - ban-name | |
# - banned-usage | |
- binary-expression-operand-order | |
- double-literal-format | |
- format-comment: | |
only-doc-comments: true | |
ignored-patterns: | |
- ^ cSpell.* | |
# - match-class-name-pattern: | |
# entries: | |
# - path: '.*state.dart' | |
# pattern: 'State$' | |
# ignore-private: true | |
- missing-test-assertion: | |
include-assertions: | |
- verify | |
include-methods: | |
- customTest | |
- newline-before-return | |
- no-boolean-literal-compare: | |
allow-false: true | |
# - no-empty-block | |
- no-equal-arguments: | |
ignored-parameters: | |
- height | |
- width | |
- no-equal-then-else | |
# - no-magic-number: | |
# allowed: [3.14, 100, 12] | |
# allow-only-once: true | |
- no-object-declaration | |
- prefer-async-await | |
- prefer-commenting-analyzer-ignores | |
- prefer-conditional-expressions: | |
ignore-nested: true | |
# - prefer-correct-identifier-length: | |
# exceptions: [ 'a' ] | |
# max-identifier-length: 30 | |
# min-identifier-length: 4 | |
- prefer-correct-test-file-name | |
- prefer-correct-type-name: | |
excluded: [ 'exampleExclude' ] | |
min-length: 3 | |
max-length: 40 | |
- prefer-enums-by-name | |
- prefer-first | |
- prefer-immediate-return | |
- prefer-iterable-of | |
- prefer-last | |
- prefer-match-file-name | |
- prefer-moving-to-variable: | |
allowed-duplicated-chains: 3 | |
- prefer-static-class | |
- prefer-trailing-comma: | |
break-on: 2 | |
- avoid-double-slash-imports | |
- avoid-unnecessary-conditionals | |
# flutter | |
- prefer-define-hero-tag | |
- always-remove-listener | |
- avoid-border-all | |
- avoid-returning-widgets: | |
ignored-names: | |
- testFunction | |
ignored-annotations: | |
- allowedAnnotation | |
- avoid-shrink-wrap-in-lists | |
- avoid-expanded-as-spacer | |
- avoid-wrapping-in-padding | |
- check-for-equals-in-render-object-setters | |
- consistent-update-render-object | |
- prefer-const-border-radius | |
- prefer-correct-edge-insets-constructor | |
# - prefer-extracting-callbacks | |
- prefer-single-widget-per-file | |
- prefer-using-list-view | |
- use-setstate-synchronously | |
# Intl, uncomment when needed | |
# - prefer-intl-name | |
# - prefer-provide-intl-description | |
# - provide-correct-intl-args | |
- member-ordering: | |
order: | |
- constructors | |
- public-fields | |
- private-fields | |
- close-method | |
- dispose-method | |
widgets-order: | |
- constructor | |
- build-method | |
- init-state-method | |
- did-change-dependencies-method | |
- did-update-widget-method | |
- dispose-method | |
linter: | |
rules: | |
# Uncomment the following section to specify additional rules. | |
# linter: | |
# rules: | |
# - camel_case_types | |
# analyzer: | |
# exclude: | |
# - path/to/excluded/files/** | |
# For more information about the core and recommended set of lints, see | |
# https://dart.dev/go/core-lints | |
# For additional information about configuring this file, see | |
# https://dart.dev/guides/language/analysis-options |
And the Dart Code Linter Lint Rules are detailed here:
https://dcl.apps.bancolombia.com/docs/rules/
Now, let me tell you what the code metrics mean and how to generate the code metrics report.
All About Code Metrics
Code Metrics allow us to make decisions about what OOP code structures we want to use and are using. The Code Metrics offered by Dart Code Linter Are:
-Cyclomatic Complexity
-Halstead Volume
- Lines Of Code
-Maintainability Index
-Maximum Nesting Level
-Number Of Methods
-Source Lines Of Code
-Technical Debt
-Weight Of Class
Cyclomatic Complexity is for both FP and OOP. Generally, 1 to 10 is low risk, while 21 to 50 is high risk and anything over 50 is somewhat untestable code. Thus, when we get a high CC we need to break classes and functions up to reduce the CC score into smaller modules. Also, generally the CC score indicates the number of tests one should have.
Halstead Volume measures the density of the code. In short words, we want a lower HV values as that indicates that code is easier to understand.
Lines Of Code are counts of source code lines including blank lines and comments in methods and functions. The general rule is to have smaller more concise methods and functions to increase code understanding.
The Maintainability Index is computed from the SLOC, CC, and HV. It literally measures and means what it is named. Thus, we generally want a lower number.
Maximum Nesting Level, Number of Methods, Number of Parameters, Source Lines Of Code, Technical Debt, and Weight of Class are about further reducing size of methods, functions, and classes.
Note, to generate the report we have to use:
dart run dart_code_linter:metrics analyze --reporter=html lib --output-directory=reports/metrics |
And typical reports look like this:
The Global Project Report
The Lib folder
Individual Dart File Report
Conclusion
I also created an annotated analysis options file that explains all the lint rules that are set:
# This file configures the static analysis results for your project (errors, | |
# warnings, and lints). | |
# | |
# This enables the 'recommended' set of lints from `package:lints`. | |
# This set helps identify many issues that may lead to problems when running | |
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | |
# style and format. | |
# | |
# If you want a smaller set of lints you can change this to specify | |
# 'package:lints/core.yaml'. These are just the most critical lints | |
# (the recommended set includes the core lints). | |
# The core lints are also what is used by pub.dev for scoring packages. | |
# how to inclued the lint strict lint rule set | |
include: package:lint/strict.yaml | |
# package lint stric has in language block | |
# language: | |
# strict-casts: true | |
analyzer: | |
language: | |
# lint has only strict-casts marked true but VGV analytics | |
# has the rest | |
strict-inference: true | |
strict-raw-types: true | |
# errors from VGV analytics minus what lint package has | |
# package lint strict has: | |
# errors: | |
# missing_required_param: error | |
# missing_return: error | |
# todo: ignore | |
# parameter_assignments: warning | |
errors: | |
close_sinks: ignore | |
record_literal_one_positional_no_trailing_comma: error | |
collection_methods_unrelated_type: warning | |
unrelated_type_equality_checks: warning | |
# package lint strict | |
# has: | |
# exclude: | |
# - lib/generated_plugin_registrant.dart | |
exclude: | |
#- '**.freezed.dart' | |
#- '**.g.dart' | |
plugins: | |
- dart_code_linter | |
dart_code_linter: | |
# I do not use extends but have implemented my | |
# own extra lint rule list | |
anti-patterns: | |
- long-method | |
- long-parameter-list | |
metrics: | |
cyclomatic-complexity: 20 | |
halstead-volume: 150 | |
maintainability-index: 50 | |
maximum-nesting-level: 5 | |
number-of-parameters: 4 | |
number-of-methods: 10 | |
source-lines-of-code: 250 | |
technical-debt: | |
threshold: 1 | |
todo-cost: 161 | |
ignore-cost: 320 | |
ignore-for-file-cost: 396 | |
as-dynamic-cost: 322 | |
deprecated-annotations-cost: 37 | |
file-nullsafety-migration-cost: 41 | |
unit-type: "USD" | |
metrics-exclude: | |
- test/** | |
# full rules list is at | |
# https://dcl.apps.bancolombia.com/docs/rules/ | |
rules: | |
#dart | |
- avoid-substring | |
# used with sort_child_properties_last | |
- arguments-ordering: | |
child-last: true | |
# these are used to help enforce arch decisions | |
# - avoid-banned-imports | |
# - avoid-banned-types | |
- avoid-cascade-after-if-null | |
- avoid-collection-methods-with-unrelated-types | |
- avoid-duplicate-exports | |
- avoid-dynamic | |
- avoid-global-state | |
# - avoid-ignoring-return-values | |
# - avoid-late-keyword: | |
# allow-initialized: true | |
- avoid-missing-enum-constant-in-map | |
- avoid-nested-conditional-expressions | |
- avoid-non-ascii-symbols | |
# - avoid-non-null-assertion: | |
# skip-checked-fields: true | |
# - avoid-passing-async-when-sync-expected | |
# - avoid-redundant-async | |
- avoid-throw-in-catch-block | |
- avoid-top-level-members-in-tests | |
- avoid-unnecessary-type-assertions | |
- avoid-unnecessary-type-casts | |
- avoid-unrelated-type-assertions: | |
ignore-mixins: false | |
- avoid-unused-parameters: | |
ignore-inline-functions: false | |
# - ban-name | |
# - banned-usage | |
- binary-expression-operand-order | |
- double-literal-format | |
- format-comment: | |
only-doc-comments: true | |
ignored-patterns: | |
- ^ cSpell.* | |
# - match-class-name-pattern: | |
# entries: | |
# - path: '.*state.dart' | |
# pattern: 'State$' | |
# ignore-private: true | |
- missing-test-assertion: | |
include-assertions: | |
- verify | |
include-methods: | |
- customTest | |
- newline-before-return | |
- no-boolean-literal-compare: | |
allow-false: true | |
# - no-empty-block | |
- no-equal-arguments: | |
ignored-parameters: | |
- height | |
- width | |
- no-equal-then-else | |
# - no-magic-number: | |
# allowed: [3.14, 100, 12] | |
# allow-only-once: true | |
- no-object-declaration | |
- prefer-async-await | |
- prefer-commenting-analyzer-ignores | |
- prefer-conditional-expressions: | |
ignore-nested: true | |
# - prefer-correct-identifier-length: | |
# exceptions: [ 'a' ] | |
# max-identifier-length: 30 | |
# min-identifier-length: 4 | |
- prefer-correct-test-file-name | |
- prefer-correct-type-name: | |
excluded: [ 'exampleExclude' ] | |
min-length: 3 | |
max-length: 40 | |
- prefer-enums-by-name | |
- prefer-first | |
- prefer-immediate-return | |
- prefer-iterable-of | |
- prefer-last | |
- prefer-match-file-name | |
- prefer-moving-to-variable: | |
allowed-duplicated-chains: 3 | |
- prefer-static-class | |
- prefer-trailing-comma: | |
break-on: 2 | |
- avoid-double-slash-imports | |
- avoid-unnecessary-conditionals | |
# flutter | |
- prefer-define-hero-tag | |
- always-remove-listener | |
- avoid-border-all | |
- avoid-returning-widgets: | |
ignored-names: | |
- testFunction | |
ignored-annotations: | |
- allowedAnnotation | |
- avoid-shrink-wrap-in-lists | |
- avoid-expanded-as-spacer | |
- avoid-wrapping-in-padding | |
- check-for-equals-in-render-object-setters | |
- consistent-update-render-object | |
- prefer-const-border-radius | |
- prefer-correct-edge-insets-constructor | |
# - prefer-extracting-callbacks | |
- prefer-single-widget-per-file | |
- prefer-using-list-view | |
- use-setstate-synchronously | |
# Intl, uncomment when needed | |
# - prefer-intl-name | |
# - prefer-provide-intl-description | |
# - provide-correct-intl-args | |
- member-ordering: | |
order: | |
- constructors | |
- public-fields | |
- private-fields | |
- close-method | |
- dispose-method | |
widgets-order: | |
- constructor | |
- build-method | |
- init-state-method | |
- did-change-dependencies-method | |
- did-update-widget-method | |
- dispose-method | |
# package lint strict has | |
# linter: | |
# rules: | |
# - always_declare_return_types | |
# - always_require_non_null_named_parameters | |
# - always_use_package_imports | |
# - annotate_overrides | |
# - annotate_redeclares | |
# - avoid_bool_literals_in_conditional_expressions | |
# - avoid_catching_errors | |
# - avoid_classes_with_only_static_members | |
# - avoid_dynamic_calls | |
# - avoid_double_and_int_checks | |
# - avoid_empty_else | |
# - avoid_escaping_inner_quotes | |
# - avoid_field_initializers_in_const_classes | |
# - avoid_final_parameters | |
# - avoid_function_literals_in_foreach_calls | |
# - avoid_implementing_value_types | |
# - avoid_init_to_null | |
# - avoid_multipple_declarations_per_line | |
# - avoid_null_checks_in_equality_operators | |
# - avoid_print | |
# - avoid_private_typedef_functions | |
# - avoid_redundatn_argument_values | |
# - avoid_relative_lib_imports | |
# - avoid_return_types_on_setters | |
# - avoid_returning_nulkl_for_future | |
# - avoid_returning_null_for_void | |
# - avoid_setters_without_getters | |
# - avoid_shadowing_type_parameters | |
# - avoid_single_cascade_in_expression_statements | |
# - avoid_type_to_strig | |
# - avoid_types_as+_parameter_names | |
# - avoid_unnecessary_containers | |
# - avoid_unsed_constructor_parameters | |
# - avoid_void_async | |
# - avoid_web_libraries_in_flutter | |
# - avoid_only_futures | |
# - camel_case_extensions | |
# - camel_case_types | |
# - camel_subscrip[tions | |
# - cast_nullable_to_non_nullable | |
# - collection_methods_unrelated_type | |
# - combinators_ordering | |
# - conditional_uri_does_not_exist | |
# - constant_identifier_names | |
# - control_flow_in_finally | |
# - curly_braces_in_flow_control_structures | |
# - dangling_library_doc_comments | |
# - depend_on_referenced_packages | |
# - deprecated_consistency | |
# - directives_ordering | |
# - empty_catches | |
# - empty_constructor_bodies | |
# - empty_statements | |
# - eol_at_ende_of_file | |
# - exhaustive_cases | |
# - file_names | |
# - hash_and_equals | |
# - implementation_imports | |
# - implicit_call_tearoffs | |
# - invalid_case_patterns | |
# - join_return_with_assignment | |
# - leading_newlines_in_multiline_strings | |
# - library_annotations | |
# - library_names | |
# - library_prefixes | |
# - missing_whitespace_between_adjacent_strings | |
# - no_adjacent_strings_in_list | |
# - no_duplicate_case_values | |
# - no_leading_underscores_for_library_prefixes | |
# - no_leading_underscores_for_locat_identifiers | |
# - no_logic_in_create_state | |
# - no_runtimeType_toString | |
# - no-self_assignments | |
# - no_wildcard_variable_uses | |
# - non_constant_identifier_names | |
# - noop_primitive_operations | |
# - null_check_on_nullable_type_parameter | |
# - null_closures | |
# - overridden_fields | |
# - package_names | |
# - package_prefixed_library_names | |
# - parameter_assignments | |
# - prefer_asserts_in_initializer_lists | |
# - prefer_collection_literals | |
# - prefer_conditional_assignment | |
# - prefer_const_constructors | |
# - prefer_const_constructors_in_immutables | |
# - prefer_const_declarations | |
# - prefer_const_literals_to_create_immutables | |
# - prefer_constructors_over_static_methods | |
# - prefer_contains | |
# - prefer_final_fields | |
# - prefer_final_in_for_each | |
# - prefer_final_locals | |
# - prefer_for_elements_to_map_fromIterable | |
# - prefer_function_declarations_over_variables | |
# - prefer_generic_function_type_aliases | |
# - prefer_if_elements_to_conditional_expressions | |
# - prefer_if_null_operators | |
# - prefer_initializing_formals | |
# - prefer_inlined_adds | |
# - prefer_interpolation_to_compose_strings | |
# - prefer_is_empty | |
# - prefer_is_not_empty | |
# - prefer_is_not_operator | |
# - prefer_iterable_whereType | |
# - prefer_null_aware_method_calls | |
# - prefer_null_aware_operators | |
# - prefer_spread_collections | |
# - prefer_typing_uninitialized_variables | |
# - prefer_void_to_null | |
# - provide_deprecation_message | |
# - recursive_getters | |
# - require_trailing_commas | |
# - secure_pubspec_urls | |
# - sized_box_for_whitespace | |
# - sized_box_shrink_expand | |
# - slash_for_doc_comments | |
# - sort_child_properties_last | |
# - sort_pub_dependencies | |
# - sort_unnamed_constructors_first | |
# - test_types_in_equals | |
# - throw_in_finally | |
# - tighten_type_of_initializing_formals | |
# - type_annotate_public_apis | |
# - type_init_formals | |
# - type_literal_in_constant_pattern | |
# - unnecessary_brace_in_string_interps | |
# - unnecessary_breaks | |
# - unnecessary_const | |
# - unnecessary_getters_setters | |
# - unnecessary_late | |
# - unnecessary_library_directive | |
# - unnecessary_new | |
# - unnecessary_null_aware_assignments | |
# - unnecessary_null_aware_operator_on_extension_on_nullable | |
# - unnecessary_null_checks | |
# - unnecessary_null_in_if_null_operators | |
# - unnecessary_nullable_for_final_variable_declarations | |
# - unnecessary_overrides | |
# - unnecessary_parenthesis | |
# - unnecessary_raw_strings | |
# - unnecessary_statements | |
# - unnecessary_string_escapes | |
# - unnecessary_string_interpolations | |
# - unnecessary_this | |
# - unnecessary_to_list_in_spreads | |
# - unreachable_from_main | |
# - unrealted_type_equality_checks | |
# - unsafe_html | |
# - use_build_context_synchoronously | |
# - use_colored_box | |
# - use_enums | |
# - use_full_hex_values_for_flutter_colors | |
# - use_function_type_syntax_for_parameters | |
# - use_is_even_rather_than_modulo | |
# - use_named_constants | |
# - use_late_for_private_fields_andd_variables | |
# - use_rethrow_when_possible | |
# - use_setters_to_change_properties | |
# - use_string_buffers | |
# - use_string_in_part_of_directives | |
# - use_super_parameters | |
# - use_test_throw_matchers | |
# - valid_regexps | |
# - void_checks | |
linter: | |
rules: | |
# Uncomment the following section to specify additional rules. | |
# linter: | |
# rules: | |
# - camel_case_types | |
# analyzer: | |
# exclude: | |
# - path/to/excluded/files/** | |
# For more information about the core and recommended set of lints, see | |
# https://dart.dev/go/core-lints | |
# For additional information about configuring this file, see | |
# https://dart.dev/guides/language/analysis-options |
This is part of the free stuff as I have 3 common chapters that are the same with each flutter book I am writing and plus it gives an idea of what the paid raw chapters are like if you want to become a paid founder memember.