creation_with_non_type
The name '{0}' isn't a class.
Description
#The analyzer produces this diagnostic when an instance creation using
either new
or const
specifies a name that isn't defined as a class.
Example
#The following code produces this diagnostic because f
is a function
rather than a class:
dart
int f() => 0;
void g() {
new f();
}
Common fixes
#If a class should be created, then replace the invalid name with the name of a valid class:
dart
int f() => 0;
void g() {
new Object();
}
If the name is the name of a function and you want that function to be
invoked, then remove the new
or const
keyword:
dart
int f() => 0;
void g() {
f();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。