目錄
目錄

Prefer null aware method calls.

This rule is available as of Dart 2.14.0.

Details

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 rule, add prefer_null_aware_method_calls under linter > rules in your analysis_options.yaml file:

linter:
  rules:
    - prefer_null_aware_method_calls