dead_code
Dead code.
Dead code: The assigned-to wildcard variable is marked late and can never be referenced so this initializer will never be evaluated.
Description
#The analyzer produces this diagnostic when code is found that won't be executed because execution will never reach the code.
Example
#The following code produces this diagnostic because the invocation of print
occurs after the function has returned:
void f() {
return;
print('here');
}
Common fixes
#If the code isn't needed, then remove it:
void f() {
return;
}
If the code needs to be executed, then either move the code to a place where it will be executed:
void f() {
print('here');
return;
}
Or, rewrite the code before it, so that it can be reached:
void f({bool skipPrinting = true}) {
if (skipPrinting) {
return;
}
print('here');
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.