> ## 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 Prefix Decrement

The `--` operator is a unary arithmetic decrement operator that evaluates its operand minus `1`, yields a new object representing that value, and updates the operand's reference to point to this new object. Because numbers in Dart are immutable, this operator does not mutate the existing value in memory; instead, it performs a reassignment. It requires a mutable variable (non-`final` and non-`const`) and functions in two distinct evaluation modes based on its syntactic position: prefix and postfix.

**Prefix Decrement (`--var`)**
When the operator precedes the operand, Dart executes a pre-decrement operation. At runtime, the expression evaluates the operand minus `1`, updates the variable's reference to the newly created object, and then yields this new value as the result of the expression.

```dart theme={"dark"}
int prefixVar = 10;
int result = --prefixVar; 

// Runtime execution order:
// 1. Evaluates prefixVar - 1 (yields a new integer object, 9)
// 2. Updates the prefixVar reference to point to 9
// 3. result is assigned the new value (9)
```

**Postfix Decrement (`var--`)**
When the operator follows the operand, Dart executes a post-decrement operation. At runtime, the expression caches the variable's current object reference to yield as the final result, evaluates the operand minus `1` to create a new object, and updates the variable's reference to this new object.

```dart theme={"dark"}
int postfixVar = 10;
int result = postfixVar--; 

// Runtime execution order:
// 1. Caches the current reference of postfixVar (10)
// 2. Evaluates postfixVar - 1 (yields a new integer object, 9)
// 3. Updates the postfixVar reference to point to 9
// 4. result is assigned the cached reference (10)
```

**Underlying Mechanics**
While conceptually similar to the assignment expression `var = var - 1`, the `--` operator provides a strict single-evaluation guarantee. For complex assignable expressions (l-values) like `list[getIndex()]--` or `getObj().prop--`, Dart evaluates the receiver and any index expressions exactly *once* at runtime. A literal `var = var - 1` expansion would incorrectly evaluate those components twice.

To use the `--` operator, the following conditions must be met:

1. The operand must be an assignable expression (a mutable l-value).
2. The operand's type must implement the subtraction operator (`operator -`) accepting an `int` as the right-hand operand.
3. The return type of that `operator -` must be assignable back to the original variable's static type to satisfy the implicit assignment step.

While natively applied to `int` and `double` types, the `--` operator functions on custom class instances provided the class explicitly overrides `operator -` and adheres to the type assignability requirement.

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