Programming in Dart: Fundamentals

Apr 26 2022 · Dart 2.15, DartPad, DartPad

Part 2: Introducing Collections & Null Safety

11. Operate on a List

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 10. Create a List Next episode: 12. Challenge: Work with Lists

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

So you’ve learned how to create lists, and how to append elements to them, using the append method and the += operator.

const pastries = ['cookie', 'cupcake', 'donut', 'pie'];
print(pastries[0]);
print(pastries[100]);
var morePastries = pastries.sublist(1, 3);
print(morePastries);
morePastries.clear();
print(evenmMorePastries);
print(evenMorePastries.isEmpty);
print(pastries[0]);
print(pastries.first);
print(pastries.last);
print(pastries.length);
print(pastries.contains('cookie'));
print(pastries.contains('lasagna'));
var pastries = ['cookie', 'cupcake', 'donut', 'pie'];
pastries.add('brownie');
print(pastries);
pastries[4] = 'cream puff';
pastries.insert(1, 'tart');
print(pastries);
var pastry = pastries.removeAt(0);
print(pastry);