immutable 0.0.4

  • Example
  • Installing
  • Versions
  • 47


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


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.



  • 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.


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


  • Add ImmutableQueue class.


  • 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

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
30 / 100
Code health derived from static analysis. [more]
80 / 100
Reflects how tidy and up-to-date the package is. [more]
39 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:immutable/immutable.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 errors 3 hints.

    Strong-mode analysis of lib/src/hamt_immutable_map.dart failed with the following error:

    line: 66 col: 13
    The function expression type '(K) → K' isn't of type '(dynamic) → K'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Run dartfmt to format lib/src/avl_immutable_list.dart.

    Similar analysis of the following files failed:

    • lib/src/internal/binary_tree.dart (hint)
    • lib/src/internal/stack.dart (hint)
  • Package is getting outdated.

    The package was released 83 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
quiver_check >=1.0.0-dev.1 <1.1.0 1.0.0
Dev dependencies
quiver_iterables >=1.0.0-dev.1 <1.1.0
test >=0.12.0 <0.13.0