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

In Dart, **Runes** are an iterable sequence of 32-bit Unicode code points that represent a string. Because Dart strings are inherently sequences of UTF-16 code units, characters outside the Basic Multilingual Plane (BMP)—such as emojis or complex symbols—are represented in memory by surrogate pairs (two 16-bit units). The `Runes` class abstracts this UTF-16 encoding complexity, allowing developers to interact directly with the underlying 32-bit Unicode code points.

## Syntax and String Literals

Within a Dart string literal, Unicode code points are expressed using the `\u` escape sequence followed by a hexadecimal value.

* **4-digit hexadecimal:** Used for characters within the BMP.
* **Curly braces `{}`:** Required for hexadecimal values containing more or fewer than 4 digits (characters outside the BMP).

```dart theme={"dark"}
String heart = '\u2665';          // 4-digit hex (BMP)
String rocket = '\u{1F680}';      // 5-digit hex (Non-BMP, requires braces)
```

## Technical Mechanics: `codeUnits` vs `runes`

The distinction between a standard Dart `String` and `Runes` becomes apparent when inspecting string length and character data. A string's `.length` property returns the number of UTF-16 code units, not the number of visible characters. The `.runes` property returns an `Iterable<int>` representing the actual Unicode code points.

```dart theme={"dark"}
String emoji = '🚀'; 

// UTF-16 Representation
print(emoji.length);          // Output: 2 (Surrogate pair)
print(emoji.codeUnits);       // Output: [55357, 56960]

// 32-bit Unicode Representation
print(emoji.runes.length);    // Output: 1 (Single code point)
print(emoji.runes);           // Output: (128640)
```

## Instantiation and Conversion

You can instantiate a `Runes` object directly from a string, and you can reconstruct a `String` from an iterable of runes using the `String.fromCharCodes()` constructor.

```dart theme={"dark"}
// Extracting runes from a string
Runes runeSequence = Runes('\u2665 \u{1f605}');

// Iterating over the 32-bit integers
for (int codePoint in runeSequence) {
  print(codePoint); 
  // Output: 9829, 32, 128517
}

// Reconstructing a String from Runes
String reconstructed = String.fromCharCodes(runeSequence);
print(reconstructed); // Output: ♥ 😅
```

## Character API Alternative

While `Runes` provide raw integer code points, Dart also offers the `characters` package (often exposed via the `String.characters` extension). While `Runes` handle 32-bit code points, `characters` handle *grapheme clusters* (user-perceived characters), which is necessary when a single visual character is composed of multiple Unicode code points (e.g., an emoji with a skin tone modifier).

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