> ## 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 Wildcard Pattern

The wildcard pattern (`_`) is a non-binding pattern that successfully matches any value or type without assigning it to a variable. It acts as an explicit discard mechanism during pattern matching, destructuring, and variable declaration, signaling to the compiler that the matched data is intentionally dropped from the lexical scope.

## Syntax and Mechanics

The wildcard pattern is represented by a single underscore (`_`). Because it does not bind to a variable, it can be used multiple times within the same pattern or scope without causing naming collisions.

### Standalone Wildcard

When used on its own, the wildcard matches any value. In `switch` statements or expressions, it functions as the exhaustive catch-all (replacing the legacy `default` keyword).

```dart theme={"dark"}
var result = switch (expression) {
  1 => 'One',
  2 => 'Two',
  _ => 'Other' // Matches any value not explicitly handled above
};
```

### Typed Wildcard

The wildcard can be prefixed with a type annotation. This creates a pattern that matches only if the value is of the specified type, but still discards the value itself.

```dart theme={"dark"}
switch (dynamicValue) {
  case int _:
    print('Value is an integer, but the value is not bound.');
  case String _:
    print('Value is a string, but the value is not bound.');
}
```

### Destructuring Collections

In list, map, and record patterns, the wildcard is used to structurally match the shape of the collection while selectively ignoring specific positional or named elements.

```dart theme={"dark"}
// Record destructuring: matches a 3-element record, discards the second element
var (first, _, third) = (1, 2, 3);

// List destructuring: matches a 4-element list, discards the middle two elements
var [start, _, _, end] = [10, 20, 30, 40];

// Map destructuring: matches the key 'b' but discards its value
var {'a': aVal, 'b': _} = {'a': 1, 'b': 2};
```

## Technical Characteristics

1. **Non-Binding Nature:** In pattern contexts (introduced in Dart 3.0), `_` is strictly a structural placeholder. Attempting to read or reference `_` as a variable after it has been used in a pattern results in a compile-time error.
2. **Multiplicity:** Unlike standard variable identifiers, `_` can be repeated infinitely within the same destructuring assignment or pattern match.
3. **Logical Operators:** The wildcard is frequently combined with logical-or (`|`) and logical-and (`&`) patterns to satisfy structural requirements without polluting the local scope with unused variables.

```dart theme={"dark"}
// Using multiple wildcards in a single logical-or pattern
if (shape case (int _, double _) | (double _, int _)) {
  print('Matches a mixed numeric coordinate pair');
}
```

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