> ## 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 Null-Aware Spread

The `...?` (null-aware spread) operator evaluates an expression that yields a collection, and if that collection is not `null`, unpacks its elements into the surrounding collection literal. If the evaluated expression is `null`, the operator safely ignores it and performs no operation, preventing runtime null dereference exceptions.

## Syntax

The operator is placed immediately preceding the nullable collection identifier or expression within a collection literal (List, Set, or Map).

```dart theme={"dark"}
// For Lists and Sets (operates on Iterables)
[elementA, ...?nullableIterable, elementB]
{elementA, ...?nullableIterable, elementB}

// For Maps (operates on Map entries)
{keyA: valueA, ...?nullableMap, keyB: valueB}
```

## Evaluation Mechanics

When the Dart compiler encounters the `...?` operator, it executes the following logical sequence:

1. **Expression Evaluation:** It evaluates the operand to the right of the `...?` operator.
2. **Null Check:** It checks if the resulting value is `null`.
3. **Branching:**
   * **If `null`:** The operator acts as a no-op. No elements are yielded to the surrounding collection literal, and execution proceeds to the next element in the literal.
   * **If non-null:** The operator behaves identically to the standard spread operator (`...`). It requests an `Iterator` from the collection and sequentially appends each element (or key-value pair, in the case of a Map) into the surrounding collection literal.

## Code Visualization

```dart theme={"dark"}
List<int>? nullList;
List<int>? populatedList = [2, 3];

// The nullList is safely ignored.
List<int> resultA = [1, ...?nullList, 4]; 
// Evaluates to: [1, 4]

// The populatedList is unpacked.
List<int> resultB = [1, ...?populatedList, 4]; 
// Evaluates to: [1, 2, 3, 4]
```

## Type System Interaction

Under Dart's sound null safety, the standard spread operator (`...`) requires an operand with a strictly non-nullable type (e.g., `List<T>`). Attempting to use `...` on a nullable type (e.g., `List<T>?`) results in a compile-time error.

The `...?` operator explicitly signals to the analyzer that the potential `null` state is handled. It accepts operands of type `Iterable<T>?` (for Lists/Sets) or `Map<K, V>?` (for Maps). The surrounding collection literal infers its type based on the generic type parameters of the unpacked collection, stripping away the nullability of the collection itself.

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