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

The `--` operator is a unary arithmetic decrement operator in Dart that subtracts exactly `1` from its numeric operand. It mutates the underlying variable in place and requires the operand to be a non-final, non-const variable.

The operator functions in two distinct evaluation contexts based on its placement relative to the operand: **prefix** and **postfix**.

## Prefix Decrement (`--var`)

In the prefix position, the operator performs a pre-decrement. Dart subtracts `1` from the operand *before* evaluating the expression. The expression resolves to the newly decremented value.

```dart theme={"dark"}
int a = 5;
int b = --a; 

// Evaluation sequence:
// 1. a is decremented by 1 (a becomes 4)
// 2. The expression resolves to the new value of a (4)
// 3. b is assigned 4
```

## Postfix Decrement (`var--`)

In the postfix position, the operator performs a post-decrement. Dart evaluates the expression using the current value of the operand, and subtracts `1` from the operand *after* the evaluation is complete.

```dart theme={"dark"}
int x = 5;
int y = x--; 

// Evaluation sequence:
// 1. The expression resolves to the current value of x (5)
// 2. y is assigned 5
// 3. x is decremented by 1 (x becomes 4)
```

## Technical Constraints and Behavior

* **Type Requirements:** The operand must be of type `num` (`int` or `double`), or a custom class that implements the `-` operator.
* **Immutability:** Applying `--` to a `final` or `const` variable results in a compile-time error, as the operator fundamentally requires reassignment.
* **Desugaring:** Dart does not allow direct overriding of the `--` operator. Instead, the Dart compiler treats `a--` or `--a` as syntactic sugar for `a = a - 1`.
* **Custom Classes:** Because of the desugaring mechanism, if you want to use the `--` operator on an instance of a custom class, you must override the binary `-` operator. The class must also be assigned to a mutable variable (`var` or explicit type, not `final`).

```dart theme={"dark"}
class Counter {
  final int value;
  Counter(this.value);

  // Overriding the binary '-' operator enables the '--' operator
  Counter operator -(int amount) => Counter(value - amount);
}

void main() {
  Counter c = Counter(10);
  c--; // Implicitly executes: c = c - 1;
}
```

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