0Pricing
Dart Academy · Lesson

Generic Collections in Practice

Type List, Map, and custom containers.

Collections Are Generic

Dart's everyday collections are all generic. List, Set, and Map each take type parameters that lock in what they hold. 📦

Typing a List

A List takes one type parameter for its elements. Declaring List of String means every item must be a String.

List<String> names = ['Ada', 'Linus'];

All lessons in this course

  1. Why Generics Beat dynamic
  2. Generic Classes and Methods
  3. Bounded Type Parameters With extends
  4. Generic Collections in Practice
← Back to Dart Academy