π¦ Dart Collections
Dart has three core collection types: List, Set, and Map. They help store and manage groups of data.
π Example: List
Console output will appear here...
π Collection Types
- List β an ordered group of items. Can have duplicates.
List list = [];
- Set β an unordered group of unique items. No duplicates allowed.
Set numbers = {1, 2, 3};
- Map β a collection of key-value pairs.
Map ages = {"Alex": 25};
π οΈ Operations You Can Do
- Add values:
list.add("Orange");
- Remove values:
list.remove("Apple");
- Check if contains:
list.contains("Banana");
- Access by index:
list[0]
- Get list length:
list.length
π‘ Use Set if you donβt want duplicates, and Map when you need to associate keys to values.