0Pricing
Dart Academy · Lesson

Records: Lightweight Tuples

Group values without a class.

Records: Lightweight Tuples is a free Dart Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is a Record?

A record is a quick way to bundle a few values together without writing a whole class. Think of it as a tiny, ready-made container. 📦

Why Tuples Matter

Sometimes you just need to group two or three values for a moment. A tuple lets you do that instantly, no boilerplate, no naming a new type.

Creating a Record

You build a record with parentheses around comma-separated values. Dart figures out the shape and types for you on the spot.

var point = (3, 7);
print(point);

Records Hold Mixed Types

A single record can mix types freely. Each slot keeps its own type, so you can pair an int with a String without any fuss.

var user = ('Ada', 36, true);
print(user);

The Record Type Annotation

You can spell out a record's type with parentheses too. It mirrors the values: one type per position, separated by commas.

(int, String) pair = (1, 'one');
print(pair);

Records Are Immutable

Once a record is made, its fields cannot change. This immutability makes records safe to share and easy to reason about.

Records Compare by Value

Two records are equal when their fields are equal in the same order. This value equality comes for free, no extra code needed.

print((1, 2) == (1, 2));

Returning Two Values

The classic win: a function can return a record to hand back multiple values at once, instead of just one.

(int, int) minMax() => (1, 9);
print(minMax());

No Class Required

Before records, returning a pair meant defining a class or using a List. Records skip all that ceremony for short-lived groupings.

Records Live on the Stack of Ideas

Reach for a record when the grouping is temporary or local. For long-lived, meaningful data with behavior, a real class still wins.

A Record in a Variable

Store a record in a variable and pass it around like any value. Dart keeps full type safety the whole way through.

var coord = (10.0, 20.0);
print(coord);

Quick Check

Which statement about Dart records is true?

Recap: Records

Nice work! 🎉 Records are lightweight tuples: parentheses around values, immutable, value-compared, and perfect for returning multiple results without a class.

Frequently asked questions

Is the “Records: Lightweight Tuples” lesson free?

Yes — the full text of “Records: Lightweight Tuples” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.

What will I learn in “Records: Lightweight Tuples”?

Group values without a class. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Dart Academy?

No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Records: Lightweight Tuples” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Dart Academy lesson?

Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Records: Lightweight Tuples
  2. Positional and Named Record Fields
  3. Destructuring With Patterns
  4. switch Patterns and Guards
← Back to Dart Academy