super. prefix.
When the Dart compiler encounters a super.identifier in a constructor’s parameter list, it automatically maps and forwards it to the invoked superclass constructor, eliminating boilerplate code.
Syntax Comparison
Prior to Dart 2.17, forwarding parameters required redundant declarations in both the constructor signature and the initializer list. Legacy Approach (Explicit Forwarding):Technical Characteristics
1. Type Inference and Explicit Typing The type of a super parameter is implicitly inferred from the corresponding parameter in the superclass constructor. However, Dart fully allows explicit type annotations on super parameters. This is typically utilized when a subclass needs to restrict the parameter to a stricter subtype than what the superclass accepts.super. in the subclass does not need to match the name of the corresponding positional parameter in the superclass.
super.value = 20) results in a compile-time error. A super parameter implicitly inherits the default value defined in the superclass. If a subclass must provide a different default value, it must declare a standard parameter and explicitly forward it to the superclass via the initializer list.
super() invocations in the initializer list:
- If a subclass constructor uses any positional super parameters, it is a compile-time error to include an explicit
super(...)invocation that passes any positional arguments. - If a subclass constructor uses a named super parameter (e.g.,
super.y), it is a compile-time error to pass an argument for that specific named parameter in an explicitsuper(...)invocation.
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More





