Menu
Coddy logo textTech

What are Maps?

Part of the Fundamentals section of Coddy's Dart journey — lesson 56 of 94.

Maps in Dart are collections that store key-value pairs. Each value is associated with a unique key, allowing you to look up values quickly.

Create a simple map with string keys and integer values:

Map<String, int> scores = {
  'John': 90,
  'Alice': 85,
  'Bob': 78
};
print(scores);

After executing the above code, the output will be:

{John: 90, Alice: 85, Bob: 78}

Maps are useful for storing related data where you need to look up values using a specific identifier (key).

Cheat sheet

Maps in Dart store key-value pairs where each value is associated with a unique key:

Map<String, int> scores = {
  'John': 90,
  'Alice': 85,
  'Bob': 78
};
print(scores); // Output: {John: 90, Alice: 85, Bob: 78}

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals