【flutter】泛型类型判断
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中是无法运行的
更多推荐
已为社区贡献6条内容
所有评论(0)