prefer_null_aware_method_calls

Group: style

Maturity: stable

Dart SDK: >= 2.14.0 • (Linter v1.3.0)

Since info is static, may be stale

View all Lint Rules

Using the Linter

Instead of checking nullability of a function/method f before calling it you can use f?.call().

BAD:

if (f != null) f!();

GOOD:

f?.call();

Usage

To enable the prefer_null_aware_method_calls lint, add prefer_null_aware_method_calls under linter > rules in your analysis_options.yaml file:

linter:
  rules:
    - prefer_null_aware_method_calls