> ## 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 Type Test

The `is` operator is a runtime type test operator that evaluates whether an object is an instance of a specified type or its subtype. It returns a boolean `true` if the object's runtime type matches the specified type hierarchy, and `false` otherwise.

Dart also provides the `is!` operator, which is the exact logical negation of `is`, returning `true` if the object is *not* an instance of the specified type.

## Syntax

```dart theme={"dark"}
expression is Type
expression is! Type
```

## Core Mechanics

**1. Subtype Resolution**
The `is` operator respects Dart's object-oriented inheritance and interface implementations. If a class `Child` extends or implements `Parent`, evaluating a `Child` instance against the `Parent` type yields `true`.

```dart theme={"dark"}
class Parent {}
class Child extends Parent {}

Parent obj = Child();
bool result1 = obj is Child;  // true
bool result2 = obj is Parent; // true
bool result3 = obj is Object; // true
```

**2. Type Promotion via Flow Analysis**
When the `is` operator is used in a conditional statement (like `if` or `switch`), the Dart analyzer performs control flow analysis. If the test evaluates to `true`, the compiler automatically promotes the variable from its declared type to the tested type within the scope of that execution branch. This promotion only applies to local variables and parameters, not to instance variables or getters, as their values could change asynchronously.

```dart theme={"dark"}
Object data = "Dart";

if (data is String) {
  // Within this block, 'data' is statically promoted to type 'String'.
  // String-specific members are now accessible without explicit casting.
  int len = data.length; 
}
```

**3. Nullability Handling**
The `is` operator strictly evaluates against Dart's sound null safety system. Testing a `null` value against a non-nullable type evaluates to `false`. Testing a `null` value against a nullable type (denoted by `?`) evaluates to `true`.

```dart theme={"dark"}
int? nullableValue = null;

bool test1 = nullableValue is int;  // false
bool test2 = nullableValue is int?; // true
```

**4. Generic Type Reification**
Because Dart uses reified generics, the `is` operator can evaluate the specific type arguments of generic collections at runtime, unlike languages that use type erasure.

```dart theme={"dark"}
Object list = <int>[1, 2, 3];

bool isIntList = list is List<int>;       // true
bool isStringList = list is List<String>; // false
```

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