Search packages, repositories and app categories

Package detailsv0.5.5

sortedmap

A map of objects which can be sorted and filtered on both their key and value

AndroidiOSWebmacOSWindowsLinux
30-day downloads
39.2K
Likes
43
Pub points
160

Install package

flutter pub add sortedmap

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

SortedMap is a Dart package that extends the functionality of standard maps by enabling sorting and filtering based on both keys and values. It provides a dynamic, type-safe way to manage key-value pairs while maintaining order according to user-defined criteria. Ideal for applications requiring ordered data retrieval, such as real-time dashboards or data analysis tools, it supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. The package integrates seamlessly with Flutter projects via pub.dev and offers intuitive APIs for common operations like filtering, mapping, and iterating over sorted entries.

Use cases

  • Real-time data dashboards
  • Ordered data storage
  • Dynamic filtering of key-value pairs
  • Data analysis applications
  • User interface state management
  • Sorting large datasets efficiently

Key features

  • Sort by key or value
  • Filter entries dynamically
  • Supports all Flutter platforms
  • Type-safe operations
  • Extends Map interface
  • Efficient iteration and lookup

Suitable for

  • Developers needing ordered maps
  • Apps with real-time data updates
  • Data-heavy applications
  • Flutter developers seeking enhanced map functionality
  • Projects requiring flexible sorting and filtering

Considerations

  • Requires understanding of Dart generics
  • May impact performance with very large datasets
  • Limited to in-memory storage
  • Not suitable for persistent storage needs
  • Dependent on external package maintenance

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

SortedMap

A simple usage example:

import 'package:sortedmap/sortedmap.dart';

main() {
  var map = new SortedMap(Ordering.byValue());
  
  map.addAll({
    "a": 3,
    "b": 2,
    "c": 4,
    "d": 1
  });
  
  print(map.lastKeyBefore("c")); // a
  print(map.firstKeyAfter("d")); // b
  
}

FilteredMap

A simple usage example:

import 'package:sortedmap/sortedmap.dart';

main() {
  var map = new FilteredMap(new Filter(
    compare: (Pair a, Pair b)=>Comparable.compare(a.value, b.value),
    isValid: (Pair v) => v.key!="b",
    limit: 2));
  
  map.addAll({
    "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.

Categories

Source repository

Projects using this package

No data available yet.

Rankings