A super-initializer parameter (often referred to as a super parameter) is a syntactic feature in Dart that allows a subclass constructor to forward arguments directly to a superclass constructor without explicitly passing them through the initializer list. By applying theDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
super. prefix to a parameter in the subclass constructor signature, the Dart compiler automatically binds and routes that argument to the corresponding parameter in the superclass.
Syntax Comparison
Prior to the introduction of super initializers, forwarding parameters required declaring the parameter in the subclass and explicitly passing it via the initializer list:Parameter Resolution Mechanics
The compiler resolvessuper. parameters differently depending on whether they are positional or named.
1. Positional Parameters
When super. is applied to positional parameters, the Dart compiler maps them to the superclass constructor’s positional parameters based strictly on their declaration order.
super. is applied to named parameters, the compiler maps them to the superclass constructor’s named parameters by matching the exact identifier. Declaration order is irrelevant.
Technical Constraints and Behavior
- Type Inference: The type of a
super.parameter is implicitly inferred from the corresponding parameter in the superclass constructor. Explicitly declaring the type (e.g.,int super.id) is redundant unless you are intentionally restricting the parameter to a stricter subtype. - Interaction with Explicit Super Invocations: Super parameters can be combined with an explicit super constructor call (e.g.,
: super.named(...)) in the initializer list, but strict rules apply to prevent argument duplication or ambiguity:- Positional Parameters: If a constructor uses positional super parameters, the explicit super constructor invocation cannot contain any positional arguments. It is a compile-time error to mix positional super parameters with explicitly passed positional arguments in the
super(...)call. - Named Parameters: Named super parameters can be used alongside an explicit super call, provided the explicit call only provides other named arguments. You cannot pass a named argument in the
super(...)call if asuper.parameter is already forwarding it.
- Positional Parameters: If a constructor uses positional super parameters, the explicit super constructor invocation cannot contain any positional arguments. It is a compile-time error to mix positional super parameters with explicitly passed positional arguments in the
Master Dart with Deep Grasping Methodology!Learn More





