avoid_returning_null_for_void
Don't return 'null' from a function with a return type of 'void'.
Don't return 'null' from a method with a return type of 'void'.
Description
#The analyzer produces this diagnostic when a function that has a return
type of void
explicitly returns null
.
Example
#The following code produces this diagnostic because there is an explicit
return of null
in a void
function:
dart
void f() {
return null;
}
Common fixes
#Remove the unnecessary explicit null
:
dart
void f() {
return;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。