Thuta Learning
BasicProgrammingbeginner

Collections (Maps)

Relax. We'll talk through this in plain words — no textbook voice.

Map is used to store key-value pairs. It's important to get comfortable with the basics before you start modeling user profiles, product data, API responses, and settings data.

dart
void main() {
  Map<String, dynamic> user = {
    'name': 'Sai',
    'role': 'Developer',
    'points': 120,
    'isActive': true,
  };

  print(user['name']);
  print(user['points']);

  user['points'] = 150;
  print('Updated points: ${user['points']}');
}

String keys are paired with values. Because dynamic is used, the values can be a mix of types — String, int, bool, and so on. You'll see this pattern a lot with user data, since field types often vary.

You should see
Sai 120 Updated points: 150

Easy traps

  • Calling a key that doesn't exist can return null. For important data, check whether the key exists before you use it.
Collections (Maps) | Thuta Learning