> ## 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 Modulo Assignment

The `%=` operator is a compound assignment operator in Dart, formally known as the modulo assignment operator. It performs a modulo operation using the left-hand and right-hand operands, and assigns the resulting value back to the left-hand operand.

```dart theme={"dark"}
target %= expression;
```

This syntax is semantically equivalent to the expanded assignment, with the technical distinction that the left-hand `target` is evaluated only once:

```dart theme={"dark"}
target = target % expression;
```

**Technical Characteristics:**

* **Evaluation Order:** Dart evaluates the left-hand expression first to determine the exact assignment target (such as resolving an object reference, property getter, or array index). It then evaluates the right-hand expression, performs the modulo operation against the target's current value, and finally executes the assignment.
* **Type Constraints:** The left-hand operand must be a mutable variable or a settable property (cannot be `const` or `final` after initialization). While natively supported by Dart's built-in numeric types (`int`, `double`, `num`), the `%=` operator is not restricted to numbers; it can be applied to any custom class that explicitly overrides `operator %`.
* **Euclidean Modulo (Numeric Types):** For Dart's core numeric types, the underlying `%` operator implements Euclidean division. Consequently, the assigned remainder will always be a non-negative value, regardless of whether the left-hand or right-hand operand is negative.
* **Division by Zero (Numeric Types):** If the right-hand operand evaluates to `0`, the operation yields `NaN` (Not-a-Number) if the left-hand variable is a `double`, or throws an `UnsupportedError` if the variable is an `int`.

**Execution Example:**

```dart theme={"dark"}
int a = 10;
a %= 3; 
// 1. Evaluates the left-hand target 'a'
// 2. Evaluates 10 % 3, which results in 1
// 3. Assigns 1 back to 'a'

int b = -5;
b %= 3;
// 1. Evaluates the left-hand target 'b'
// 2. Evaluates -5 % 3. Due to Euclidean modulo, the result is 1
// 3. Assigns 1 back to 'b'

// Custom class example
class Vector {
  final int value;
  Vector(this.value);
  
  Vector operator %(int divisor) {
    return Vector(value % divisor);
  }
}

Vector v = Vector(10);
v %= 3; // Valid because Vector implements operator %
```

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