immutable 0.0.4

  • Example
  • Installing
  • Versions
  • 0

immutable #

Immutable collections for Dart. It's in its very early days and under heavy development, not ready for production use.

Usage #

A simple usage example:

import 'package:immutable/immutable.dart';

main() {
  var stack = ImmutableStack.empty.push(5);

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.0.4 #

  • Add ImmutableMap and ImmutableMapBuilder class.
  • Remove clear method from ImmutableList. Use the empty constuctor instead.
  • Remove ImmutableListBuilder.empty constructor. Call toImmutable on an empty ImmutableList instead.
  • Turn on strong mode and fix warnings and errors.

0.0.3 #

  • Add ImmutableList and ImmutableListBuilder class.
  • Replace static empty fields with factory constructors.

0.0.2 #

  • Add ImmutableQueue class.

0.0.1 #

  • Add ImmutableStack class.


// Copyright (c) 2015, <your name>. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library immutable.example;

import 'package:immutable/immutable.dart';

main() {
  var m = new ImmutableMap<int, String>.empty();
  m = m.add(1, 'a').add(2, 'b').add(3, 'c');
  print('m[1]: ${m[1]}');
  print('m[2]: ${m[2]}');
  print('m[3]: ${m[3]}');
  print('m[4]: ${m[4]}');
  print('m.length: ${m.length}');
  print('m.keys: ${m.keys}');
  print('m.values: ${m.values}');

  print('--- forEach ---');
  m.forEach((int key, String value) {
    print('key $key, value $value');

  final b = m.toBuilder();
  b[5] = 'foo';
  b[6] = 'bar';
  print('b.remove(1): ${b.remove(1)}');

  m = b.toImmutable();
  print('m[1]: ${m[1]}');
  print('m[2]: ${m[2]}');
  print('m[3]: ${m[3]}');
  print('m[5]: ${m[5]}');
  print('m[6]: ${m[6]}');

  m = m.remove(1).remove(2);
  print('m[1]: ${m[1]}');
  print('m[2]: ${m[2]}');
  print('m[3]: ${m[3]}');
  print('m.length: ${m.length}');
  print('m.keys: ${m.keys}');
  print('m.values: ${m.values}');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  immutable: ^0.0.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:immutable/immutable.dart';
Version Uploaded Documentation Archive
0.0.4 Nov 5, 2016 Go to the documentation of immutable 0.0.4 Download immutable 0.0.4 archive
0.0.3 Oct 22, 2015 Go to the documentation of immutable 0.0.3 Download immutable 0.0.3 archive
0.0.2 Sep 30, 2015 Go to the documentation of immutable 0.0.2 Download immutable 0.0.2 archive
0.0.1 Sep 29, 2015 Go to the documentation of immutable 0.0.1 Download immutable 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0