Search packages, repositories and app categories

Package detailsv5.1.3

crdt

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
2.6K
Likes
83
Pub points
150

Install package

flutter pub add crdt

Package Overview

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

A Dart implementation of Conflict-free Replicated Data Types (CRDTs), enabling consistent, real-time collaboration across distributed systems without requiring coordination. CRDTs ensure data convergence even in the presence of network partitions or concurrent updates, making them ideal for collaborative applications like shared documents, live dashboards, and multiplayer games. The package supports multiple platforms including mobile, web, and desktop, ensuring cross-platform consistency.

Use cases

  • Real-time collaborative editing
  • Distributed state synchronization
  • Offline-first applications
  • Multiplayer game state management
  • Live dashboard updates

Key features

  • Conflict-free data convergence
  • Support for multiple CRDT types
  • Cross-platform compatibility
  • Low-latency updates
  • No central coordination required

Suitable for

  • Developers building real-time apps
  • Teams needing offline-first functionality
  • Applications with distributed users
  • Collaborative tools requiring strong consistency
  • Systems with unreliable network conditions

Considerations

  • Requires understanding of CRDT principles
  • May increase data size due to replication
  • Not suitable for high-frequency atomic operations
  • Limited to specific data structures
  • Performance depends on data complexity

Original README

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

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 on the paper Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases (pdf).

It has minimal external dependencies, so it should run anywhere where Dart runs, which is pretty much everywhere.

The Crdt class implements CRDT conflict resolution and serves as a storage-agnostic interface for specific implementations. Als included with this package is MapCrdt, an ephemeral implementation using Dart HashMaps.

Other implementations include (so far):

  • hive_crdt, a no-sql implementation using Hive as persistent storage.
  • sql_crdt, an abstract implementation for using relational databases as a data storage backend.
  • sqlite_crdt, an implementation using Sqlite for storage, useful for mobile or small projects.
  • postgres_crdt, a sql_crdt that benefits from PostgreSQL's performance and scalability intended for backend applications.

See also crdt_sync, a turnkey approach for real-time network synchronization of Crdt nodes.

Usage

The simplest way to experiment with this package is to use the provided MapCrdt implementation:

import 'package:crdt/map_crdt.dart';

void main() {
  var crdt1 = MapCrdt(['table']);
  var crdt2 = MapCrdt(['table']);

  print('Inserting 2 records in crdt1…');
  crdt1.put('table', 'a', 1);
  crdt1.put('table', 'b', 1);

  print('crdt1: ${crdt1.getMap('table')}');

  print('\nInserting a conflicting record in crdt2…');
  crdt2.put('table', 'a', 2);

  print('crdt2: ${crdt2.getMap('table')}');

  print('\nMerging crdt2 into crdt1…');
  crdt1.merge(crdt2.getChangeset());

  print('crdt1: ${crdt1.getMap('table')}');
}

Implementations

crdt is currently helping build local-first experiences for:

  • Libra a weigh management app with 1M+ installs.
  • tudo an open-source simple to-do app + backend.

Are you using this package in your project? Let me know!

Features and bugs

Please file feature requests and bugs at the issue tracker.

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.