> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dart Initializer List

An initializer list is a comma-separated sequence of expressions placed between a constructor's parameter list and its body, prefixed by a colon (`:`). It executes before the constructor body runs and before the superclass constructor is invoked, allowing for the assignment of instance variables before the object is fully instantiated.

```dart theme={"dark"}
ClassName(parameterList) : initializer1, initializer2 {
  // constructor body
}
```

## Execution Order

When a constructor is invoked, Dart processes the initialization phase in a strict sequence:

1. Initializer list expressions (evaluated from left to right).
2. Superclass constructor.
3. Main class's constructor body.

## Scope and Restrictions

* **No `this` Access:** The right-hand side of an initializer expression does not have access to the `this` keyword. You cannot invoke instance methods or read instance variables within the initializer list because the object is in an uninitialized state.
* **Final Variables:** It is the primary mechanism for initializing `final` instance variables that require computation or parameter mapping before the constructor body executes.
* **Redirection Isolation:** If an initializer list contains a redirecting constructor call (`this(...)`), it cannot contain any other initializers.

## Syntax Mechanics

**Variable Assignment and Assertions**
The list can contain direct assignments to instance variables and `assert` statements for parameter validation.

```dart theme={"dark"}
import 'dart:math';

class Vector {
  final double x;
  final double y;
  final double magnitude;

  Vector(double x, double y)
      : x = x,
        y = y,
        magnitude = sqrt(x * x + y * y),
        assert(x >= 0 && y >= 0) {
    // Body executes after x, y, and magnitude are set
  }
}
```

**Superclass Delegation**
The initializer list is used to explicitly invoke a superclass constructor using `super(...)`. If omitted, Dart implicitly calls the superclass's unnamed, no-argument constructor.

```dart theme={"dark"}
class Vector3D extends Vector {
  final double z;

  Vector3D(double x, double y, double z)
      : z = z,
        super(x, y) {
    // Body executes after z is set and Vector(x, y) completes
  }
}
```

**Constructor Redirection**
When delegating to another constructor within the same class, the initializer list consists solely of the `this(...)` call.

```dart theme={"dark"}
class Vector {
  final double x;
  final double y;

  Vector(this.x, this.y);

  // Redirecting constructor
  Vector.zero() : this(0.0, 0.0); 
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Dart Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
