Recently Object
got runtimeType
getter. So, now we may not only compare type of object with another type, but actually get the class name of an object.
As in:
myObject.runtimeType.toString()
Furthermore, in the current version of Dart, you can now skip toString
operation and directly compare runtimeType
of object with target type as in
myObject.runtimeType == int
or
myObject.runtimeType == Animal
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…