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

In Dart, `Object` is the base class for all non-nullable types. Because Dart is a pure object-oriented language, every value—including primitives like integers, booleans, and functions—is an instance of a class that implicitly inherits from `Object`. Under Dart's sound null safety system, the absolute root of the type hierarchy is `Object?` (nullable Object), making `Object` the root of all types except `Null`.

## Type Hierarchy and Static Typing

Dart distinguishes between `Object`, `Object?`, and `dynamic` at the compiler level:

* **`Object`**: The top non-nullable type. A variable of type `Object` can hold any value except `null`. The compiler enforces strict type checking, allowing access only to methods defined on the `Object` class itself.
* **`Object?`**: The true top type. It is equivalent to `Object | Null`.
* **`dynamic`**: A static type annotation that tells the compiler to disable static type checking. While a `dynamic` variable can hold the same values as `Object?`, it permits arbitrary method invocations at compile time, deferring type resolution to runtime.

```dart theme={"dark"}
Object nonNullableObj = 42; // Valid
// nonNullableObj = null;   // Compile-time error

Object? nullableObj = null; // Valid

// Type checking enforcement
Object strictObj = "String value";
// strictObj.length;        // Compile-time error: 'length' is not defined on 'Object'

dynamic dynamicObj = "String value";
print(dynamicObj.length);   // Compiles and runs successfully
```

## Core Interface

Because all non-nullable classes inherit from `Object`, they inherit its core interface. These methods and properties are frequently overridden in custom classes to define specific behaviors for equality, hashing, and string representation.

### 1. `operator ==(Object other)`

Evaluates equality. By default, the `Object` implementation performs an identity check (reference equality), returning `true` only if both references point to the exact same instance in memory.

### 2. `int get hashCode`

Returns an integer representing the object's hash code. It is a strict rule in Dart that if two objects are equal according to `operator ==`, they must return the exact same `hashCode`.

### 3. `String toString()`

Returns a string representation of the object. The default implementation returns `Instance of 'ClassName'`.

### 4. `Type get runtimeType`

A property that returns the `Type` object representing the actual runtime type of the instance. It is generally evaluated at runtime and should not be used for type checking (use the `is` operator instead).

### 5. `dynamic noSuchMethod(Invocation invocation)`

Invoked automatically by the Dart runtime when code attempts to access a method or property that does not exist on the object. The default implementation throws a `NoSuchMethodError`. It returns `dynamic` to allow intercepted method calls to return values.

## Syntax: Overriding Object Methods

When defining a class, `extends Object` is implicit. Overriding the inherited `Object` methods conventionally uses the `@override` annotation. While highly recommended and enforced by standard lint rules, the `@override` annotation is not strictly required by the Dart compiler to successfully override a method.

```dart theme={"dark"}
class Entity {
  final int id;
  final String name;

  Entity(this.id, this.name);

  // Overriding == requires the parameter to be of type Object
  @override
  bool operator ==(Object other) {
    return identical(this, other) ||
        (other is Entity && 
         runtimeType == other.runtimeType && 
         id == other.id);
  }

  // hashCode must be overridden if == is overridden.
  // It must only rely on fields used in the operator == check.
  @override
  int get hashCode => id.hashCode;

  @override
  String toString() => 'Entity(id: $id, name: $name)';
}
```

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