field_initializer_factory_constructor
Details about the 'field_initializer_factory_constructor' diagnostic produced by the Dart analyzer.
Initializing formal parameters can't be used in factory constructors.
Description
#The analyzer produces this diagnostic when a factory constructor has an initializing formal parameter. Factory constructors can't assign values to fields because no instance is created; hence, there is no field to assign.
Example
#The following code produces this diagnostic because the factory constructor uses an initializing formal parameter:
class C {
int? f;
factory C(this.f) => throw 0;
}
Common fixes
#Replace the initializing formal parameter with a normal parameter:
class C {
int? f;
factory C(int f) => throw 0;
}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.