void main() {
test<int>();
}
static testT<T>() {
//判断T是否为某一类型或其子类
print(List<T>() is List<num>);
//得到T的类型
print(_typeOf<T>());
}
static Type _typeOf<T>() => T;
注意这个在dartpad中是无法运行的
void main() {
test<int>();
}
static testT<T>() {
//判断T是否为某一类型或其子类
print(List<T>() is List<num>);
//得到T的类型
print(_typeOf<T>());
}
static Type _typeOf<T>() => T;
注意这个在dartpad中是无法运行的