default_value_in_function_type
Details about the 'default_value_in_function_type' diagnostic produced by the Dart analyzer.
Parameters in a function type can't have default values.
Description
#The analyzer produces this diagnostic when a function type associated with a parameter includes optional parameters that have a default value. This isn't allowed because the default values of parameters aren't part of the function's type, and therefore including them doesn't provide any value.
Example
#
The following code produces this diagnostic because the parameter p has a
default value even though it's part of the type of the parameter g:
void f(void Function([int p = 0]) g) {
}
Common fixes
#Remove the default value from the function-type's parameter:
void f(void Function([int p]) g) {
}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.