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

`Never` is the bottom type in Dart's static type system. It represents an expression that can never successfully complete evaluation, meaning a value of type `Never` can never exist at runtime.

## Type Hierarchy and Generics

In type theory, a bottom type is a subtype of all other types. Because `Never` sits at the absolute bottom of Dart's type hierarchy, an expression of type `Never` can be assigned to a variable of *any* other type. Conversely, no type is a subtype of `Never` (except `Never` itself).

This subtyping behavior extends to generics, where `Never` acts as a strict constraint. For example, a `List<Never>` represents a list that is guaranteed to be empty because it can never accept elements. Similarly, a `Stream<Never>` represents a stream that can only emit errors or completion events, never data.

Under Dart's sound null safety, `Never` is strictly non-nullable. Its nullable counterpart, `Never?`, represents a type that can only ever contain `null`, making `Never?` functionally equivalent to the `Null` type.

## Execution Mechanics and Reachability

When a function is declared with a return type of `Never`, the Dart analyzer enforces that the function cannot return normally. The analyzer verifies this purely through reachability analysis. To satisfy the compiler, the end of the function block must be unreachable. This is achieved by:

1. Executing a `throw` or `rethrow` statement.
2. Entering an unconditionally infinite loop.
3. Calling another expression statically typed as `Never` (such as `exit()` or `Isolate.exit()`, which satisfy the analyzer simply because their signatures declare a `Never` return type).

Because the compiler guarantees a `Never` expression will halt normal control flow, any code written immediately after an expression evaluating to `Never` is statically analyzed as dead (unreachable) code.

## Syntax Visualization

```dart theme={"dark"}
// A function returning Never must interrupt control flow.
Never haltExecution() {
  throw Exception('Execution terminated');
}

Never infiniteLoop() {
  while (true) {
    // Infinite execution prevents normal return
  }
}

// Because Never is a subtype of all types, an expression evaluating 
// to Never can satisfy any static type requirement.
void assignToInt() {
  int number = haltExecution();
}

void assignToString() {
  String text = haltExecution();
}

void deadCodeDemonstration() {
  haltExecution();
  
  // The analyzer flags the following as dead code because 
  // the preceding Never expression halts control flow.
  print('This will never execute'); 
}
```

## Variable Declaration

While the syntax allows declaring a variable of type `Never`, it is impossible to initialize or assign a value to it, as no instance of `Never` can be instantiated in memory.

```dart theme={"dark"}
// Valid static declaration, but impossible to populate at runtime.
late Never impossibleValue;
```

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