Dart Super ConstructorThe child class can inherit all properties (methods, variables) and behavior of parent expect parent class constructor.& The superclass constructor can be invoke in sub class by using the super() constructor. We can access both non-parameterized and parameterized constructor of superclass. Accessing the constructor of superclass is slightly different in the Dart. The syntax is given below. Syntax:Implicit superAs we know that the constructor is automatically called when we instantiate a class. When we create the object of sub class, it invokes the constructor of sub class which implicitly invokes the parent class's default(non-parameterized) constructor. We can use super() constructor in our subclass to invoke superclass constructor. Let's understand the following example. Example -Output: Dart Implicit Superclass constructor example This is a superclass constructor This is a subclass constructor Welcome to javatpoint Explicit superIf the superclass constructor consists of parameters then we require to call super() constructor with argument in to invoke superclass constructor in subclass explicitly. Let's understand the following example. Example -Output: Dart explicit Superclass constructor example This is a parameterized superclass constructor We are calling superclass constructor explicitly This is a subclass constructor Welcome to javatpoint Example - 2Next TopicDart Methods |