redirect_to_non_class
The name '{0}' isn't a type and can't be used in a redirected constructor.
Description
#One way to implement a factory constructor is to redirect to another constructor by referencing the name of the constructor. The analyzer produces this diagnostic when the redirect is to something other than a constructor.
Example
#The following code produces this diagnostic because f
is a function:
C f() => throw 0;
class C {
factory C() = f;
}
Common fixes
#If the constructor isn't defined, then either define it or replace it with a constructor that is defined.
If the constructor is defined but the class that defines it isn't visible, then you probably need to add an import.
If you're trying to return the value returned by a function, then rewrite the constructor to return the value from the constructor's body:
C f() => throw 0;
class C {
factory C() => f();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。