crdt 1.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

Dart implementation of Conflict-free Replicated Data Types (CRDTs).

This project is heavily influenced by James Long's talk CRTDs for Mortals and includes a Dart-native implementation of Hybrid Local Clocks (HLC) based the paper Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases.

It has zero external dependencies, so it should run everywhere where Dart runs.

Usage #

The Crdt class works as a layer on top of a map. The simplest way to experiment is to initialise it an empty map:

import 'package:crdt/crdt.dart';

main() {
  var crdt = Crtd();

You'll probably want to implement Store if you want to offer any sort of persistence though.

Example #

An example of how it can be used in an application can be found at

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.2.2 #

  • Fix incrementing the HLC when merging newer records.
  • Fix counter not being able to reach maximum (0xFFFF)

1.2.1 #

  • Remove unnecessary Future in Crdt.values getter.

1.2.0 #

  • Breaking: Crdt.get() now returns the value (or null) rather than the record. Use Crdt.getRecord() for the previous behaviour.
  • API Change: Getter methods on both Crdt and Store are now synchronous.
  • API Change: Crdt.Clear() now accepts purgeRecords to determine if records should be purged or marked as deleted.
  • Add and to monitor the CRDT for changes.
  • Add Crdt.isDeleted() to check if a record has been deleted.

1.1.1 #

  • Add values getter which retrieves all values as list, excluding deleted records

1.1.0 #

  • HLCs implement Comparable
  • Support typed key and values
  • Refactor CRDT and Store to replace index operators with getters and setters
  • Add clear() method
  • Add JSON de/serialisation helper methods

1.0.0 #

  • Initial version


import 'package:crdt/crdt.dart';

void main() {
  var crdt = Crdt(MapStore({}));
  crdt.put('a', 1);
  print(crdt.get('a')); // 1

Use this package as a library

1. Depend on it

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

  crdt: ^1.2.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:crdt/crdt.dart';
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 Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.9.0
test ^1.6.0