Programming in Dart: Fundamentals

Apr 26 2022 Dart 2.15, DartPad, DartPad

Part 2: Introducing Collections & Null Safety

10. Create a List

Episode complete

Play next episode

Save for later
About this episode
See versions
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 9. Introduction Next episode: 11. Operate on a List

Dart’s List documentation: [

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

In this episode, you’ll learn about a collection type that you’ll be using in all your programs - the List otherwise known as the array. In dart, a list is synonymous with an array so you can use them interchangeably. For the sake of consistency, I’ll refer to them as Lists, but if you hear or read the word array in any Dart or a Flutter tutorial, just understand it is just a list.

const pastries =
const pastries = [];
const pastries = ["cookie", "cupcake", "donut", "pie"];
const List<String> pastries = ["cookie", "cupcake", "donut", "pie"];
var pastries = <String>[];
pastries += ['cupcake', 'donut', 'pie', 'brownie'];