Skip to main content

future_sync_value

Learn about the future_sync_value linter rule.

Unreleased
Fix available
Released in Dart 3.14

For synchronous values, Future.syncValue is more performant.

Details

#

DO use Future.syncValue when the argument is synchronous.

BAD:

dart
Future<int> f() => Future.value(1);

GOOD:

dart
Future<int> f() => Future.value(1);

Enable

#

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

analysis_options.yaml
yaml
linter:
  rules:
    - future_sync_value

If you're instead using the YAML map syntax to configure linter rules, add future_sync_value: true under linter > rules:

analysis_options.yaml
yaml
linter:
  rules:
    future_sync_value: true