prefer_expression_function_bodies
Unnecessary use of a block function body.
Description
#The analyzer produces this diagnostic when the body of a function consists of a single return statement with an expression.
Example
#The following code produces this diagnostic because the body of f
has a
single return statement:
dart
int f() {
return 0;
}
Common fixes
#If the body is complete, then replace the body with an expression body:
dart
int f() => 0;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。