Just to clarify a bit the difference between is
and runtimeType
. As someone said already (and this was tested with Dart V2+) the following code:
class Foo {
Type get runtimeType => String;
}
main() {
var foo = new Foo();
if (foo is Foo) {
print("it's a foo!");
}
print("type is ${foo.runtimeType}");
}
will output:
it's a foo!
type is String
Which is wrong. Now, I can't see the reason why one should do such a thing...