- 01Setting up (what you'll need)
- 02Your first output (print)
- 03Variables and types (var and annotations)
- 04Null safety (? and !)
- 05Branching (the if statement)
- 06Repeating (the for loop)
- 07Writing your own function
- 08Repeating (the while loop)
- 09Working with lists (List)
- 10Working with maps (Map)
- 11Classes (object orientation)
- 12Constructors
- 13Inheritance
- 14Named arguments
- 15Asynchronous work (Future, async, await)
- 16Working with strings
- 17The switch statement
- 18The ternary operator
- 19Extension methods
- 20[Project] Build a small inventory system
Working with lists (List)
This lesson covers the list, which handles several values together.
Writing List<type> creates a list of values of the same type. add() appends an element and for-in takes every element out.
The sample code creates List<String> fruits = [];, adds fruit with add(), and then displays every element with for (var f in fruits).
A common early stumble is that list indexes start at 0. A list with three elements runs from fruits[0] to fruits[2], and reaching fruits[3] is a runtime error.
In professional work, managing the data shown on screen — a product listing, say — in a list is the basic pattern in Flutter apps.
๐งช This site can't compile or run Dart directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ nothing is sent anywhere).
