我希望能够从泛型函数内部构造对象.我try 了以下方法:
abstract class Interface
{
Interface.func(int x);
}
class Test implements Interface
{
Test.func(int x){}
}
T make<T extends Interface>(int x)
{
// the next line doesn't work
return T.func(x);
}
然而,这是行不通的.我得到以下错误信息:The method 'func' isn't defined for the class 'Type'
.
Note:我不能用镜子,因为我用的是带有Flutter 的省道.