super() invocation, implicitly binding the subclass parameter to the corresponding parameter in the superclass.
Syntax and Mechanics
The syntax uses thesuper keyword followed by the parameter name (e.g., super.parameterName) within the subclass constructor’s formal parameter list.
When a super parameter is used, the associated argument is implicitly added to the superclass constructor call. The type of the parameter is inferred from the superclass constructor, though it may be explicitly annotated.
Comparison
Verbose Syntax (Standard Initializer):Positional Super Parameters
For positional parameters, the order of thesuper parameters in the subclass determines which positional parameters they map to in the superclass constructor. They are matched sequentially.
Named Super Parameters
For named parameters, the mapping is based on the parameter name. The subclass parameter name must match the name defined in the superclass constructor.Type Inference and Annotations
The type of a super parameter is inferred from the corresponding parameter in the super constructor. Explicit type annotations are permitted but generally redundant unless narrowing the type is required.Mixing Parameters
Super parameters can be mixed with initializing formals (this.prop) and standard function parameters within the same constructor signature.
Constraints
- Exclusive Initialization: If a constructor utilizes any super parameters (positional or named), it is a compile-time error to include an explicit
super()invocation in the initializer list. The compiler constructs the super call implicitly. - Name Matching: Named super parameters rely strictly on identifier equality; you cannot rename a parameter while forwarding it via
super.name. - Variable Scope: Super parameters are available within the constructor body as local variables. However, they are not bound to
thisand do not become instance fields of the subclass.
Master Dart with Deep Grasping Methodology!Learn More





