assignment_to_type
Types can't be assigned a value.
Description
#The analyzer produces this diagnostic when the name of a type name appears on the left-hand side of an assignment expression.
Example
#The following code produces this diagnostic because the assignment to the
class C
is invalid:
dart
class C {}
void f() {
C = null;
}
Common fixes
#If the right-hand side should be assigned to something else, such as a local variable, then change the left-hand side:
dart
void f() {}
void g() {
var c = null;
print(c);
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。