> ## 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 Continue Statement

The `continue` statement is a control flow construct that alters the standard sequential execution of a program. Depending on its context and syntax, it either terminates the current iteration of an enclosing loop to immediately begin the next iteration, or transfers execution to a specific labeled `case` clause within a `switch` statement.

## Syntax

```dart theme={"dark"}
// Unlabeled
continue;

// Labeled
continue labelName;
```

## Scope and Constraints

The validity and behavior of the `continue` statement depend strictly on whether a label is applied, and are bound by strict lexical constraints:

* **Unlabeled `continue`:** Strictly confined to the lexical scope of loop constructs (`for`, `for-in`, `await for`, `while`, `do-while`). Using an unlabeled `continue` outside of a loop results in a compile-time error.
* **Labeled `continue`:** Can be used within nested loops to target a specific enclosing loop, or within a `switch` statement to jump directly to a labeled `case` clause. It cannot be used as a general-purpose `goto` to reach arbitrary labels outside of these specific control flow structures.
* **Function Boundaries:** A `continue` statement cannot cross function boundaries. It is invalid to use `continue` inside a closure or local function (such as a callback passed to an `Iterable.forEach()` method) to skip an iteration of an enclosing loop.

## Execution Mechanics

### Unlabeled Continue (Loops)

When an unlabeled `continue` is encountered, the Dart runtime bypasses any remaining statements within the innermost loop's body for that specific cycle. The exact transfer of control depends on the loop type:

* **`for` loops:** Control transfers directly to the *update expression* (e.g., `i++`), followed by the evaluation of the loop condition.
* **`while` and `do-while` loops:** Control transfers directly to the *boolean condition expression*.
* **`for-in` and `await for` loops:** Control transfers to the retrieval of the next element from the underlying `Iterable` or `Stream`.

```dart theme={"dark"}
for (int i = 0; i < 4; i++) {
  if (i == 2) {
    continue; // Bypasses the print statement when i equals 2
  }
  print(i); 
}
// Output: 0, 1, 3
```

### Labeled Continue (Loops)

Dart utilizes labels (identifiers followed by a colon) to target specific loops in a nested structure. When `continue` is invoked with a loop label, it bypasses the remaining body of the current loop and jumps to the next iteration (update expression or condition evaluation) of the explicitly labeled outer loop.

```dart theme={"dark"}
outerLoop: // Label definition
for (int i = 0; i < 3; i++) {
  for (int j = 0; j < 3; j++) {
    if (i == 1 && j == 1) {
      // Terminates the inner loop and jumps to the 
      // update expression (i++) of outerLoop
      continue outerLoop; 
    }
    print('i: $i, j: $j');
  }
}
```

### Labeled Continue (Switch Statements)

Within a `switch` statement, a labeled `continue` acts as a directed jump. It transfers execution directly to another `case` clause that has been marked with the corresponding label, allowing execution to proceed from that specific case. Modern Dart (3.0+) utilizes implicit break semantics, meaning explicit `break` statements are not required to prevent fallthrough.

```dart theme={"dark"}
int statusCode = 200;

switch (statusCode) {
  case 200:
    print('OK');
    continue redirectLabel; // Jumps directly to redirectLabel
  case 404:
    print('Not Found');
  redirectLabel: // Label attached to a specific case
  case 301:
    print('Redirecting');
}
```

<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>
