default_value_on_required_parameter
Details about the 'default_value_on_required_parameter' diagnostic produced by the Dart analyzer.
Required named parameters can't have a default value.
Description
#
The analyzer produces this diagnostic when a named parameter has both the
required modifier and a default value. If the parameter is required, then
a value for the parameter is always provided at the call sites, so the
default value can never be used.
Example
#The following code generates this diagnostic:
void log({required String message = 'no message'}) {}
Common fixes
#If the parameter is really required, then remove the default value:
void log({required String message}) {}
If the parameter isn't always required, then remove the required
modifier:
void log({String message = 'no message'}) {}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.