body_ might_ complete_ normally_ nullable
This function has a nullable return type of '{0}', but ends without returning a value.
Description
#
The analyzer produces this diagnostic when a method or function can
implicitly return
null
by falling off the end. While this is valid Dart
code, it's better for the return of
null
to be explicit.
Example
#
The following code produces this diagnostic because the function
f
implicitly returns
null
:
String? f() {}
Common fixes
#If the return of null
is intentional, then make it explicit:
String? f() {
return null;
}
If the function should return a non-null value along that path, then add the missing return statement:
String? f() {
return '';
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.