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

An abstract base class in Dart is a class declared with the `abstract` modifier that cannot be directly instantiated. It serves as a structural blueprint, defining a contract of method signatures and properties that concrete subclasses must implement, while optionally providing shared concrete implementations.

## Syntax and Declaration

To define an abstract class, precede the `class` keyword with the `abstract` modifier. Abstract methods within the class are defined by terminating the method signature with a semicolon instead of providing a method body.

```dart theme={"dark"}
abstract class AbstractBase {
  // Instance variable
  String baseProperty;

  // Constructor
  AbstractBase(this.baseProperty);

  // Abstract method: Signature only, no body
  void abstractMethod();

  // Concrete method: Fully implemented
  void concreteMethod() {
    print('Executing concrete method. Property: $baseProperty');
  }
}
```

## Core Technical Rules

**1. Instantiation Restriction**
Attempting to instantiate an abstract class directly results in a compile-time error.

```dart theme={"dark"}
// Compile-time error: Abstract classes can't be instantiated.
var instance = AbstractBase('value'); 
```

**2. Subclassing (`extends`)**
When a concrete class extends an abstract base class, it inherits all concrete members and must provide implementations for all abstract methods.

```dart theme={"dark"}
class ConcreteSubclass extends AbstractBase {
  ConcreteSubclass(String baseProperty) : super(baseProperty);

  // Must override the abstract method
  @override
  void abstractMethod() {
    print('Implemented abstract method');
  }
}
```

**3. Implicit Interfaces (`implements`)**
Like all classes in Dart, an abstract class implicitly defines an interface. If a class `implements` an abstract class rather than extending it, it must provide implementations for *all* members of the abstract class, including concrete methods and instance variables.

```dart theme={"dark"}
class InterfaceImplementation implements AbstractBase {
  // Must implement the instance variable
  @override
  String baseProperty;

  InterfaceImplementation(this.baseProperty);

  // Must implement the abstract method
  @override
  void abstractMethod() {
    print('Implemented abstract method');
  }

  // Must ALSO implement the concrete method
  @override
  void concreteMethod() {
    print('Re-implemented concrete method');
  }
}
```

**4. Abstract Subclasses**
A class that extends an abstract base class can itself be declared `abstract`. In this scenario, the subclass is not required to implement the inherited abstract methods; the implementation burden is deferred to the next concrete subclass in the inheritance hierarchy.

```dart theme={"dark"}
abstract class IntermediateAbstract extends AbstractBase {
  IntermediateAbstract(String baseProperty) : super(baseProperty);
  
  // abstractMethod() remains unimplemented here
  
  void additionalAbstractMethod();
}
```

**5. Factory Constructors**
While an abstract class cannot be instantiated directly, it can define a `factory` constructor that returns an instance of a concrete subclass. This allows the abstract class to act as an entry point for instantiation logic without violating the instantiation restriction.

```dart theme={"dark"}
abstract class AbstractWithFactory {
  factory AbstractWithFactory() {
    return ConcreteImplementation();
  }
  
  void doWork();
}

class ConcreteImplementation implements AbstractWithFactory {
  @override
  void doWork() {}
}
```

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