0
0
Fluttermobile~10 mins

Lists, Maps, and Sets in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a list of strings named fruits.

Flutter
List<String> fruits = [1];
Drag options to blanks, or click blank then click option'
A["apple", "banana", "cherry"]
B("apple", "banana", "cherry")
C{"apple", "banana", "cherry"}
D<"apple", "banana", "cherry">
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses () instead of square brackets []
Using curly braces {} which create sets or maps
Using angle brackets <> which are for generics, not collections
2fill in blank
medium

Complete the code to access the value for key 'name' in the map.

Flutter
Map<String, String> person = {"name": "Alice", "city": "Paris"};
String name = person[1];
Drag options to blanks, or click blank then click option'
A[0]
B["name"]
C.name
D("name")
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation which does not work for map keys
Using parentheses which is invalid syntax
Using an index number which is for lists, not maps
3fill in blank
hard

Fix the error in the code to add an item to the set.

Flutter
Set<int> numbers = {1, 2, 3};
numbers[1](4);
Drag options to blanks, or click blank then click option'
Apush
Bappend
Cadd
Dinsert
Attempts:
3 left
💡 Hint
Common Mistakes
Using append or push which are list methods
Using insert which is not a method for sets
Trying to add items with assignment instead of a method
4fill in blank
hard

Fill both blanks to create a map from a list of keys and a list of values.

Flutter
List<String> keys = ["a", "b", "c"];
List<int> values = [1, 2, 3];
Map<String, int> map = Map.fromIterables([1], [2]);
Drag options to blanks, or click blank then click option'
Akeys
Bvalues
Citems
Delements
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping keys and values
Using undefined variables like items or elements
Passing only one argument instead of two
5fill in blank
hard

Fill all three blanks to create a set from a list and add a new item.

Flutter
List<int> nums = [1, 2, 3];
Set<int> numSet = [1](nums);
numSet.[2](4);
bool hasFour = numSet.[3](4);
Drag options to blanks, or click blank then click option'
ASet.from
Badd
Ccontains
DList.of
Attempts:
3 left
💡 Hint
Common Mistakes
Using List.of instead of Set.from
Using wrong method names like insert or push
Checking membership with wrong methods