immutable 0.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 47

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);
  print(stack.peek());
}

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.

example/immutable.dart

// 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');
  });
  print('---------------');

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

  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:


dependencies:
  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

Analysis

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

Scores

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

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

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

Dependencies

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