Skip to main content

prefer-explicit-function-type

Warns when a Function type does not specify the return type and arguments.

Not specifying the return type and the list of arguments can lead to hard-to-spot bugs since the Function type effectively makes the declaration dynamic and disables type checks.

Example

❌ Bad:

class SomeWidget {
// LINT: This 'Function' type does not specify a return type or parameter list. Try adding them.
final Function onTap;

const SomeWidget(this.onTap);
}

✅ Good:

class SomeWidget {
final void Function() onTap;

const SomeWidget(this.onTap);
}