O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unmodifiable collections

The collection framework has unmodifiable versions of the existing collections with the following advantages:

  • To make a collection immutable once it has been built and not modify the original collection to guarantee absolute immutability, although the elements in that collection are still mutable
  • To allow read-only access to your data structure from the client code and the client code can look into it without modifying it while you have full access to the original collection

The unmodifiable list

The unmodifiable collection based on the List class is UnmodifiableListView. It creates an unmodifiable list backed by the source provided via the argument of the constructor:

import 'dart:collection'; void main() { var list = new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required