future_sync_value
Learn about the future_sync_value linter rule.
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
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.13.0 版本报告页面问题.