Harap dicatat bahwa postingan blog ini diterbitkan pada Januari 2014, jadi tergantung kapan Anda membacanya, beberapa bagian mungkin sudah kedaluwarsa. Sayangnya, saya tidak selalu dapat memperbarui postingan ini secara lengkap untuk memastikan keakuratan informasinya.
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");
}
}