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

The `*=` operator is a compound assignment operator that multiplies the current value of the left operand by the value of the right operand, and subsequently assigns the resulting product back to the left operand.

## Syntax

```dart theme={"dark"}
leftOperand *= rightOperand;
```

## Technical Mechanics

* **Evaluation Order:** Dart evaluates expressions strictly left-to-right. The left operand (the receiver/target) is evaluated first, followed by the right operand. The multiplication is then performed, and the result is assigned back to the left operand.
* **Single Evaluation:** The compound assignment operator evaluates the `leftOperand` exactly *once*. This makes `leftOperand *= rightOperand` technically distinct from the expanded form `leftOperand = leftOperand * rightOperand` when the left operand contains side effects. For example, `list[i++] *= 2` increments `i` only once, whereas `list[i++] = list[i++] * 2` would evaluate the left operand twice, incrementing `i` twice.
* **Mutability:** The left operand must be a mutable reference. It cannot be declared as `const` or `final`.
* **Operator Overloading:** The `*=` operator is not restricted to core numeric types. It functions by invoking the `operator *` method on the left operand. It can be used with any custom class that implements `operator *`.

## Type Safety and Promotion Rules

Because Dart is statically typed, the result of the multiplication operation must be assignable to the declared type of the left operand.

**Numeric Types**
When using Dart's core numeric types (`int`, `double`, `num`), type promotion dictates the following behaviors:

* **Integer Assignment:** If both operands are integers, the result is an integer and safely assigns back to an `int` variable.
* **Double Assignment:** If the left operand is a `double`, the right operand can be either an `int` or a `double`. The result will always be a `double`.
* **Compile-Time Type Errors:** If the left operand is strictly typed as an `int` and the right operand is a `double`, the multiplication yields a `double`. Dart will not implicitly downcast a `double` to an `int`, resulting in a compile-time error.

```dart theme={"dark"}
int a = 5;
a *= 3; // Evaluates to 15. Type remains int.

double b = 2.5;
b *= 2; // Evaluates to 5.0. Type remains double.

int c = 4;
// c *= 1.5; // COMPILE ERROR: A value of type 'double' can't be assigned to a variable of type 'int'.
```

**Custom Types**
When using `*=` with custom classes, the return type of the overloaded `operator *` must be assignable to the variable's type, and the right operand must match the parameter type defined in the method signature.

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

  Vector operator *(int scalar) => Vector(value * scalar);
}

Vector v = Vector(2);
v *= 3; // Valid: Invokes `operator *` and assigns the resulting Vector(6) back to `v`.
```

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