Open
Description
An immediately invoked function expression (IIFE) is a quick and common way to embed multiple statements, followed by a return statement, where only an expression is expected.
I think a refactoring for wrapping an expression in an IIFE would be very helpful.
Here is a simple concrete example:
Initial program:
void main() {
final foo = MapEntry(
0,
1,
);
}
Refactored program:
void main() {
final foo = MapEntry(
() {
return 0;
}(),
1,
);
}
The usefulness of such a refactoring becomes much more apparent when considered in a context where e.g. big Trees need to be constructed (as is common in Flutter). Having the statements close to the related expression is useful for improving code readability, but manually wrapping expressions in IIFEs is very tedious.