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

class, comparison, dart, instance

Solution

a.runtimeType == b.runtimeType

Problem

Let's say I get two instances in my code and I don't know their types. How to check it? If in Java, I can use this code: ``` a.getClass() == b.getClass() ``` But in Dart, I can't find similar methods. Although there is the `dart:mirrors` providing `reflect(instance)` function, which may let me do it, but I'm not sure if that's a correct solution since it looks complicated.

Original source

Related problems