0
0
Fluttermobile~20 mins

Lists, Maps, and Sets in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
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
intermediate
2: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(),
)
AA single Text widget showing 'AnnaBobCara' concatenated
BAn empty screen with no text
CA vertical list showing: Anna, Bob, Cara each on its own line
DA runtime error because ListView children must be widgets
Attempts:
2 left
💡 Hint
Think about how map and toList create widgets for each name.
🧠 Conceptual
intermediate
1:30remaining
How does a Dart Map store data?
In Dart, what is the main characteristic of a Map collection?
AIt stores only integer values indexed by position
BIt stores only unique values without keys
CIt stores ordered elements like a list
DIt stores key-value pairs where keys are unique and values can be any type
Attempts:
2 left
💡 Hint
Think about how you look up a phone number by a person's name.
📝 Syntax
advanced
1: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);
APrints 4 because duplicates are ignored in sets
BPrints 5 because duplicates are allowed in sets
CSyntaxError because duplicate values are not allowed in set literals
DRuntime error because sets cannot contain integers
Attempts:
2 left
💡 Hint
Remember what a set means in math: no duplicates.
lifecycle
advanced
2: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?
ACalling setState() to notify Flutter to rebuild the widget
BChanging the List automatically rebuilds the UI without extra code
CYou must manually refresh the screen outside Flutter
DFlutter rebuilds only when the app restarts
Attempts:
2 left
💡 Hint
Think about how Flutter knows when to redraw the screen.
🔧 Debug
expert
2: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']!);
APrints null because 'Cara' is not in the map
BThrows a runtime error because 'Cara' key does not exist and ! forces non-null
CSyntax error because ! cannot be used with map access
DPrints 0 because missing keys default to zero
Attempts:
2 left
💡 Hint
Consider what happens when you force a null value to be non-null.