Challenge - 5 Problems
Master of Lists, Maps, and Sets
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the output of this Flutter List display?
Consider this Flutter code snippet that displays a list of names in a ListView. What will be shown on the screen?
Flutter
List<String> names = ['Anna', 'Bob', 'Cara']; ListView( children: names.map((name) => Text(name)).toList(), )
Attempts:
2 left
💡 Hint
Think about how map and toList create widgets for each name.
✗ Incorrect
The map function creates a Text widget for each name. The ListView shows these widgets vertically.
🧠 Conceptual
intermediate1:30remaining
How does a Dart Map store data?
In Dart, what is the main characteristic of a Map collection?
Attempts:
2 left
💡 Hint
Think about how you look up a phone number by a person's name.
✗ Incorrect
A Map stores data as pairs: each key is unique and maps to a value.
📝 Syntax
advanced1:30remaining
What error does this Dart Set code cause?
What error will this Dart code produce?
Set numbers = {1, 2, 3, 3, 4};
print(numbers.length);
Flutter
Set<int> numbers = {1, 2, 3, 3, 4}; print(numbers.length);
Attempts:
2 left
💡 Hint
Remember what a set means in math: no duplicates.
✗ Incorrect
Sets automatically remove duplicates, so the length counts unique values only.
❓ lifecycle
advanced2:00remaining
How does Flutter rebuild widgets when a List changes?
If you update a List used in a Flutter widget's build method, what triggers the UI to update?
Attempts:
2 left
💡 Hint
Think about how Flutter knows when to redraw the screen.
✗ Incorrect
Flutter rebuilds widgets when setState() is called to notify changes.
🔧 Debug
expert2:30remaining
Why does this Flutter Map access cause an error?
Given this Dart Map:
Map ages = {'Alice': 30, 'Bob': 25};
What error occurs when running:
print(ages['Cara']!);
Flutter
Map<String, int> ages = {'Alice': 30, 'Bob': 25}; print(ages['Cara']!);
Attempts:
2 left
💡 Hint
Consider what happens when you force a null value to be non-null.
✗ Incorrect
The ! operator asserts the value is not null, but 'Cara' key is missing, so it throws an error.