【发布时间】:2014-05-19 17:47:13
【问题描述】:
我有测试应用:
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。这甚至可能吗?如果我检查参数类型属性为空。
【问题讨论】:
标签: reflection dart dart-mirrors