missing_return
This function has a return type of '{0}', but doesn't end with a return statement.
Description
#Any function or method that doesn't end with either an explicit return or a
throw implicitly returns null
. This is rarely the desired behavior. The
analyzer produces this diagnostic when it finds an implicit return.
Example
#The following code produces this diagnostic because f
doesn't end with a
return:
dart
int f(int x) {
if (x < 0) {
return 0;
}
}
Common fixes
#除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。