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

A base class in Dart is a class that establishes an inheritance hierarchy by allowing other classes to inherit its properties and methods. In Dart 3 and later, `base` is a specific class modifier that restricts how a class can be consumed across library boundaries, explicitly permitting inheritance (`extends`) while strictly prohibiting interface implementation (`implements`).

## The `base` Modifier Mechanics

When a class is declared with the `base` modifier, Dart enforces the following compiler-level guarantees:

1. **Extension is permitted:** External classes can use the `extends` keyword to inherit from the base class.
2. **Implementation is prohibited externally:** Classes outside of the defining library cannot use the `implements` keyword to treat the base class as an interface.
3. **Modifier propagation:** Any class that extends *or implements* a `base` class must be marked as `base`, `final`, or `sealed`. While implementing a `base` class is prohibited externally, it is perfectly valid within the same library. Enforcing the modifier on implementing classes ensures that external libraries cannot bypass the `base` restriction by implementing a subtype.

```dart theme={"dark"}
// library_a.dart
base class CoreSystem {
  int systemId;

  CoreSystem(this.systemId);

  void initialize() {
    print('System $systemId initialized');
  }
}

// VALID: Implementing a base class is allowed WITHIN the same library.
// The implementing class MUST propagate the restriction (base, final, or sealed).
final class InternalMockSystem implements CoreSystem {
  @override
  int systemId;

  InternalMockSystem(this.systemId);

  @override
  void initialize() {}
}
```

```dart theme={"dark"}
// library_b.dart
import 'library_a.dart';

// VALID: Extending a base class is allowed outside its library.
// The subclass MUST propagate the restriction (base, final, or sealed).
base class SubSystem extends CoreSystem {
  SubSystem(super.systemId);
}

// INVALID: Implementing a base class outside its library causes a compile-time error.
class ExternalMockSystem implements CoreSystem {
  // Compile error: The class 'CoreSystem' can't be implemented outside of its library
  // because it's a base class.
}
```

## Abstract Base Classes

The `base` modifier can be combined with the `abstract` modifier. An `abstract base` class cannot be instantiated directly and forces subclasses to provide implementations for its abstract members, while still preventing external libraries from using it as an interface.

```dart theme={"dark"}
abstract base class DataProcessor {
  // Abstract method requiring implementation in subclasses
  void process(List<int> data);

  // Concrete method inherited by subclasses
  void log(String message) {
    print(message);
  }
}

// Subclasses must implement process() and must declare a valid modifier
final class ImageProcessor extends DataProcessor {
  @override
  void process(List<int> data) {
    // Implementation details
  }
}
```

## The Implicit Base Class: `Object`

In the Dart type system, if a class does not explicitly extend another class, it implicitly extends `Object`. Therefore, `Object` serves as the ultimate base class for the entire Dart class hierarchy (with the exception of `Null`), providing foundational methods such as `toString()`, `hashCode`, and `operator ==`.

```dart theme={"dark"}
// This declaration:
class Entity {}

// Is semantically equivalent to:
class Entity extends Object {}
```

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