简体   繁体   中英

How to get the type of something in Dart?

I have the line of code below from a tutorial I am following, but with my version of Flutter this syntax is wrong:

I am using Flutter 1.7.8 and the tutorial is using 0.11.2, so I guess this is an issue with my version of Dart.

final type = _typeOf<BlocProvider<T>>();

How can I convert the code above to the latest version of Dart?

_typeOf isn't part of the language. You have to implement it yourself.

It's fairly straightforward:

Type _typeOf<T>() => T;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM