我有测试应用程序:
import 'dart:mirrors';
class A {
void eventHandlerInt(List<int> x){}
void eventHandlerBool(List<bool> x){}
}
void testMirrors(aFunction){
ClosureMirror mir = reflect(aFunction);
var param = mir.function.parameters.first;
//How to get the Type T of List<T> of the first param?
}
void main() {
var a = new A();
testMirrors(a.eventHandlerInt);
testMirrors(a.eventHandlerBool);
}
我希望能够找出传入方法的第一个参数的泛型类型是什么testMirrors
,因此在上面的示例中就是int
这样bool
。这甚至可能吗?如果我检查参数类型属性为空。