Flutter判断泛型类型

Posted 亦游

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter判断泛型类型相关的知识,希望对你有一定的参考价值。

在Dart中判断泛型类型时可以用如下方法:

	void main() 
		test<int>();
	

  static testT<T>() 
 	 //判断T是否为某一类型或其子类
    print(List<T>() is List<num>);
    //得到T的类型
    print(typeOf<T>());
  

  static Type typeOf<T>() => T;

以上是关于Flutter判断泛型类型的主要内容,如果未能解决你的问题,请参考以下文章