- 01Setting up (what you'll need)
- 02Your first output (print)
- 03Variables and types (var and annotations)
- 04Null safety (? and !)
- 05Branching (the if statement)
- 06Repeating (the for loop)
- 07Writing your own function
- 08Repeating (the while loop)
- 09Working with lists (List)
- 10Working with maps (Map)
- 11Classes (object orientation)
- 12Constructors
- 13Inheritance
- 14Named arguments
- 15Asynchronous work (Future, async, await)
- 16Working with strings
- 17The switch statement
- 18The ternary operator
- 19Extension methods
- 20[Project] Build a small inventory system
Working with maps (Map)
This lesson covers the map, which manages data as key-value pairs.
Writing Map<keyType, valueType> creates a structure where you look up a value by its key. It corresponds to a dictionary or associative array in other languages.
The sample code builds a map of products and prices — Map<String, int> prices = {'apple': 100, 'orange': 80}; — and reads a value out with prices['apple'].
A common early stumble is that reaching for a key that does not exist returns null. When you read from a map, stay aware of whether the key is actually there.
In professional work, JSON received from an API is very often handled as a Map, which makes Dart's map operations an essential everyday skill.
๐งช This site can't compile or run Dart directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ nothing is sent anywhere).
