我对dart还比较新,仍在努力理解它的所有细微差别。根据特定情况,我想做的一件事是将一个类/类型作为参数传递给函数,以便访问一些静态方法和属性。
以下是一个例子:
class WithStatic {
static final test = 'wwww';
}
void main() {
print(WithStatic.test);
test(WithStatic);
}
void test(dynamic cls){
// throws error Class '_Type' has no instance getter 'test'
print(cls.test);
}