Breno Rios Ramos
Breno Rios Ramos

Reputation: 419

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?

Upvotes: 1

Views: 421

Answers (1)

R&#233;mi Rousselet
R&#233;mi Rousselet

Reputation: 277027

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

It's fairly straightforward:

Type _typeOf<T>() => T;

Upvotes: 1

Related Questions