How to determine if two instances have the same type, in Dart? How to determine if two instances have the same type, in Dart? dart dart

How to determine if two instances have the same type, in Dart?


if you want to compare a and b you can use

if(a.runtimeType == b.runtimeType);

but if you want to confirm that a is the type you want you need to do this

if(a.runtimeType.toString()=="DivElement");//a is a div for instance

because runtimeType's value is not a string