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

The `*` (asterisk) in Dart functions primarily as a binary infix operator for multiplicative operations, and lexically as a suffix modifier for generator functions and yield delegation.

## The Binary Operator (`*`)

As an operator, `*` is a syntactic sugar for a method call on the left operand. It possesses **multiplicative precedence** (level 14 in Dart's precedence table), meaning it evaluates after unary operators but before additive operators, with **left-to-right associativity**.

### Built-in Implementations

**1. Numeric Multiplication**
When applied to `num` types (`int` or `double`), it performs standard arithmetic multiplication. The return type is determined by the operands: if both are `int`, it returns an `int`; if either is a `double`, it returns a `double`.

```dart theme={"dark"}
int a = 5 * 2;       // Evaluates to 10
double b = 5.0 * 2;  // Evaluates to 10.0
```

**2. String Repetition**
Dart's `String` class implements the `*` operator, accepting an `int` as the right operand. It returns a new string containing the original string repeated the specified number of times.

```dart theme={"dark"}
String repeated = 'Dart' * 3; // Evaluates to 'DartDartDart'
```

### Operator Overloading

Because `*` is implemented as an instance method, it can be overridden in user-defined classes using the `operator` keyword. The right operand can be of any type specified by the method signature.

```dart theme={"dark"}
class Matrix {
  final List<int> values;
  Matrix(this.values);

  // Overloading the * operator
  Matrix operator *(int scalar) {
    return Matrix(values.map((v) => v * scalar).toList());
  }
}

Matrix m1 = Matrix([1, 2, 3]);
Matrix m2 = m1 * 2; 
```

## Lexical Modifiers (Generators)

Beyond binary operations, the `*` symbol is a structural component of Dart's generator syntax. It modifies the behavior of functions and the `yield` keyword.

**1. `sync*` and `async*`**
Appending `*` to the `sync` or `async` keywords transforms a standard function into a generator function.

* `sync*` forces the function to return an `Iterable<T>` and evaluates synchronously.
* `async*` forces the function to return a `Stream<T>` and evaluates asynchronously.

```dart theme={"dark"}
Iterable<int> synchronousGenerator() sync* {
  yield 1;
}

Stream<int> asynchronousGenerator() async* {
  yield 1;
}
```

**2. `yield*` (Yield Delegation)**
When appended to the `yield` keyword, `*` delegates the emission of values to another `Iterable` or `Stream`. Instead of emitting the collection as a single object, `yield*` flattens the sequence, emitting each element of the delegated collection individually into the current generator's output.

```dart theme={"dark"}
Iterable<int> delegatedGenerator() sync* {
  yield* synchronousGenerator(); 
}
```

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