sortedmap 0.4.2

  • Installing
  • Versions
  • 83

Contains a SortedMap and FilteredMap class, which hold a map of objects that can be ordered relative to each other.

Unlike SplayTreeMap the objects can be ordered on both key and value or a combination of both.

The FilteredMap also allows to specify an isValid function on key/value pairs and limit the number of objects allowed in the map.


A simple usage example:

import 'package:sortedmap/sortedmap.dart';

main() {
  var map = new SortedMap((Pair a, Pair b)=>, b.value));
    "a": 3,
    "b": 2,
    "c": 4,
    "d": 1
  print(map.lastKeyBefore("c")); // a
  print(map.firstKeyAfter("d")); // b


A simple usage example:

import 'package:sortedmap/sortedmap.dart';

main() {
  var map = new FilteredMap(new Filter(
    compare: (Pair a, Pair b)=>, b.value),
    isValid: (Pair v) => v.key!="b",
    limit: 2));
    "a": 3,
    "b": 2,
    "c": 4,
    "d": 1
  print(map.keys); // (d, a)

Features and bugs

Please file feature requests and bugs at the issue tracker.



  • Support Dart 2 in pubspec.yaml


  • fixes on Dart 2 compatibility


  • Dart 2 pre-release compatibility


  • performance improvements


  • resolve strong mode analysis warnings
  • change dependency on quiver to <0.28.0


  • new FilteredMapView class
  • some api changes


  • keep elements after limit in FilteredMap


  • compare and isValid methods iso getters in Filter
  • strong mode fixes
  • linter


  • Initial version

Use this package as a library

1. Depend on it

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

  sortedmap: ^0.4.2

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:sortedmap/sortedmap.dart';
Version Uploaded Documentation Archive
0.4.2 Aug 14, 2018 Go to the documentation of sortedmap 0.4.2 Download sortedmap 0.4.2 archive
0.4.1 Jul 18, 2018 Go to the documentation of sortedmap 0.4.1 Download sortedmap 0.4.1 archive
0.4.0 Jul 12, 2018 Go to the documentation of sortedmap 0.4.0 Download sortedmap 0.4.0 archive
0.3.1 Jul 12, 2018 Go to the documentation of sortedmap 0.3.1 Download sortedmap 0.3.1 archive
0.3.0 Mar 19, 2018 Go to the documentation of sortedmap 0.3.0 Download sortedmap 0.3.0 archive
0.2.0 Mar 7, 2017 Go to the documentation of sortedmap 0.2.0 Download sortedmap 0.2.0 archive
0.1.2 Feb 10, 2017 Go to the documentation of sortedmap 0.1.2 Download sortedmap 0.1.2 archive
0.1.1 Jun 17, 2016 Go to the documentation of sortedmap 0.1.1 Download sortedmap 0.1.1 archive
0.1.0 Jun 7, 2016 Go to the documentation of sortedmap 0.1.0 Download sortedmap 0.1.0 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.

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

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/sortedmap.dart.

Run dartfmt to format lib/sortedmap.dart.

Format lib/src/filter.dart.

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

Format lib/src/filteredmap.dart.

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

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/ordering.dart (Run dartfmt to format lib/src/ordering.dart.)
  • lib/src/sortedmap.dart (Run dartfmt to format lib/src/sortedmap.dart.)
  • lib/src/treemap.dart (Run dartfmt to format lib/src/treemap.dart.)
  • lib/src/treeset.dart (Run dartfmt to format lib/src/treeset.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use sortedmap.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.14.0 <3.0.0
quiver >=0.22.0 <3.0.0 2.0.1
Transitive dependencies
matcher 0.12.4
meta 1.1.6
path 1.6.2
stack_trace 1.9.3
Dev dependencies
benchmark_harness ^1.0.4
test >=0.12.0 <2.0.0