请注意,这篇博文发布于2014年1月,因此根据您阅读的时间,某些部分可能已经过时。很遗憾,我无法始终保持这些文章的完全更新,以确保信息的准确性。
Even though (at the time this article was written at least) it is not explicitly documented here is how to call on a super class' constructor in the Dart language.
So given we have this abstract class:
abstract class Animal {
String name;
Animal( String this.name );
}
If you are only interested in calling the super's constructor in your sub class' constructor you can write this one liner:
class Dog extends Animal {
Dog() : super("Spot");
}
Or if you want to do additional logic in the sub class' constructor you can expand the super call like this:
class Dog extends Animal {
Dog() : super("Spot") {
print("Dog was created");
}
}