Lint rules to warn you about common misuse of Grab and fix it quickly.

Setup

This plugin uses custom_lint.

pubspec.yaml

Put the latest version in place of x.x.x below.

dev_dependencies:
  custom_lint:
  grab_lints: x.x.x

analysis_options.yaml

analyzer:
  plugins:
    - custom_lint

Available lints

Errors

RuleFixDetails
missing_grab_mixin A necessary Grab mixin is missing in the with clause.
wrong_grab_mixin The widget class has a mismatching Grab mixin in the with clause.

Warnings

RuleFixDetails
unnecessary_grab_mixin An unnecessary Grab mixin is in the with clause.
maybe_wrong_build_context_for_grab (✅) The BuildContext passed to the grab method has either of the following issues:
  • Not the one from the build method
  • Passed via a variable
The BuildContext parameter itself of the build method should be directly used to avoid misuse or confusion.

Quick fix is available only when an automatic fix is possible.
avoid_grab_outside_build A grab method has been used outside the build method of a widget.

It is discouraged although using the method outside the build method is possible as long as the correct BuildContext is used. Such usage easily leads to misuse or confusion.

Libraries

grab_lints