Small program
Combine collections and async into a small service.
What you will be able to do
- Model with a class.
- Fetch and map results.
- Print a summary.
In plain English
Combine collections and async into a small service.
- Model with a class.
- Fetch and map results.
- Print a summary.
class Lesson {
const Lesson(this.title, this.minutes);
final String title;
final int minutes;
}
void main() {
const lessons = [Lesson('HTML', 12), Lesson('CSS', 18)];
final total = lessons.fold<int>(0, (sum, l) => sum + l.minutes);
print(total);
}Your turn
EasyExplain it back
Answer from memory: Which method folds a collection into one value?
TEXT · starter
Your answer…Check your understanding before moving on.
Knowledge checkQuestion 1
Which method folds a collection into one value?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.