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

A `mixin class` in Dart is a declaration that combines the capabilities of both a standard class and a mixin. Introduced in Dart 3.0 to enforce strict type modifiers, it allows a single structure to be instantiated directly, extended as a superclass, or mixed into other class hierarchies using the `with` keyword.

## Syntax and Behavior

To define a mixin class, prepend the `class` keyword with the `mixin` modifier.

```dart theme={"dark"}
mixin class Diagnostic {
  int errorCount = 0;
  
  void recordError() {
    errorCount++;
  }
}
```

Because it is both a class and a mixin, the Dart compiler permits three distinct operations on this single declaration:

```dart theme={"dark"}
// 1. Instantiation (acting as a class)
Diagnostic diagnosticTool = Diagnostic();

// 2. Extension (acting as a superclass)
class AdvancedDiagnostic extends Diagnostic {
  void reset() => errorCount = 0;
}

// 3. Mixing in (acting as a mixin)
class NetworkService with Diagnostic {
  void fetch() {
    // Can access mixin class members directly
    recordError(); 
  }
}
```

## Structural Constraints

To satisfy the compiler requirements of both a class and a mixin simultaneously, a `mixin class` is subject to strict structural limitations:

1. **No Generative Constructors:** A `mixin class` cannot declare any custom generative constructors. It must rely exclusively on the implicit, unnamed, no-argument default constructor.

```dart theme={"dark"}
// INVALID: Cannot declare a constructor in a mixin class
mixin class Diagnostic {
  Diagnostic(this.errorCount); 
}
```

2. **No `extends` Clause:** A `mixin class` cannot extend any class other than the implicit `Object`. It must sit at the root of its own inheritance hierarchy.

```dart theme={"dark"}
class BaseSystem {}

// INVALID: A mixin class cannot have an extends clause
mixin class Diagnostic extends BaseSystem {} 
```

3. **No `on` Clause:** Unlike a pure `mixin`, a `mixin class` cannot use the `on` keyword to restrict the types of classes it can be mixed into. It must be universally applicable to any class.

```dart theme={"dark"}
// INVALID: The 'on' clause is exclusive to pure mixins
mixin class Diagnostic on BaseSystem {} 
```

## Modifier Comparison Matrix

Understanding `mixin class` requires distinguishing it from its base components under Dart 3.0 semantics:

| Modifier      | Can be instantiated? | Can be extended (`extends`)? | Can be mixed in (`with`)? | Can use `on` clause? |
| :------------ | :------------------- | :--------------------------- | :------------------------ | :------------------- |
| `class`       | Yes                  | Yes                          | No                        | No                   |
| `mixin`       | No                   | No                           | Yes                       | Yes                  |
| `mixin class` | Yes                  | Yes                          | Yes                       | No                   |

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