Dead codeDRT-W1284
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');
}