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

The `@override` annotation is a metadata marker used to explicitly indicate that an instance member (method, getter, setter, or variable) in a subclass is intended to replace a member with the identical name in its superclass or implemented interface.

When the Dart analyzer encounters the `@override` annotation, it performs a strict compile-time check against the class hierarchy. If the annotated member does not exist in any direct or indirect supertype, the compiler throws an error. This enforces contract adherence and prevents silent failures caused by typographical errors in method names or upstream changes to superclass signatures.

## Syntax and Application

The annotation is placed immediately preceding the member declaration.

```dart theme={"dark"}
class BaseClass {
  String get identifier => 'Base';
  
  void execute(int code) {
    // Implementation
  }
}

class DerivedClass extends BaseClass {
  @override
  String get identifier => 'Derived';

  @override
  void execute(int code) {
    // Overridden implementation
  }
}
```

## Technical Constraints and Rules

* **Target Validity:** `@override` can only be applied to instance methods, instance variables, getters, and setters.
* **Static Members:** It cannot be applied to `static` members, as static members belong to the class itself and do not participate in inheritance or dynamic dispatch.
* **Constructors:** It cannot be applied to constructors, including factory constructors.
* **Signature Compatibility:** The overriding member must adhere to Dart's sound typing rules regarding variance:
  * **Return Types (Covariance):** The return type of the overriding member must be the same as, or a subtype of, the overridden member's return type.
  * **Parameters (Contravariance):** The parameter types of the overriding method must be the same as, or a supertype of, the overridden method's parameters (unless explicitly marked with the `covariant` keyword).
  * **Optional Parameters:** The overriding method must accept at least the same optional parameters as the overridden method.

## Uniform Access Principle

Because Dart implements the Uniform Access Principle, the `@override` annotation is valid when crossing member types between fields and accessors. A subclass can override a superclass instance variable with a getter/setter pair, or override a superclass getter with a final instance variable.

```dart theme={"dark"}
class SuperType {
  int value = 0;
}

class SubType extends SuperType {
  @override
  int get value => 42;

  @override
  set value(int v) {
    // Custom setter logic
  }
}
```

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