Flutter判断泛型类型
来源:www.jianshu.com 更新时间:2023-05-25 21:55
void main() {
test<int>();
}
static testT<T>() {
//判断T是否为某一类型或其子类
print(List<T>() is List<num>);
//得到T的类型
print(typeOf<T>());
}
static Type typeOf<T>() => T;
test<int>();
}
static testT<T>() {
//判断T是否为某一类型或其子类
print(List<T>() is List<num>);
//得到T的类型
print(typeOf<T>());
}
static Type typeOf<T>() => T;