Hierarchical Inheritance in Dart Programming

Dart ProgrammingServer Side ProgrammingProgramming

Hierarchical inheritance is the case of inheritance when two classes inherit a single class.

The syntactic representation of a hierarchical inheritance looks something like this −

class A {}
class B extends A {}
class C extends A {}

In the above syntactic representation, we can see that two classes, namely B and C are inheriting (or extending) class A.


Let's consider an example of hierarchical inheritance in dart. Consider the example shown below −

 Live Demo

class Parent{
   void printName(){
      print("Inside class Parent");

class Daughter extends Parent{
   void age(age){
      print("Her age is: ${age}");

class Son extends Parent{
   void name(name){
      print("My name is: ${name}");

void main(){
   Daughter d = new Daughter();

   Son s = new Son();

In the above example, we have two classes, namely Son and Daughter that are extending the class named Parent.


Inside class Parent
Her age is: 23
Inside class Parent
My name is: Tuts
Published on 21-May-2021 12:50:02