avoid_ returning_ null_ for_ void
Details about the 'avoid_returning_null_for_void' diagnostic produced by the Dart analyzer.
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:
void f() {
return null;
}
Common fixes
#Remove the unnecessary explicit null:
void f() {
return;
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.