passnote 1.1.2
passnote: ^1.1.2 copied to clipboard
End-to-end encrypted, server-less, local-first CRDT sync engine for Dart: typed collections, queries, SQLite storage, device identity, sync protocol.
// Two stores converge by exchanging changesets: the merge is idempotent and
// order-independent, which is the property everything else builds on. A real
// app opens collections through `passnoteBuilder` (package:passnote_flutter)
// or `Passnote.builder`; a real deployment stores in `SqliteCrdtTable` and
// syncs over a transport.
import 'package:passnote/engine.dart';
Future<void> main() async {
final alice = MapCrdtTable('todos');
final bob = MapCrdtTable('todos');
await alice.put('todos', 'milk', {'title': 'Milk', 'done': false});
await bob.put('todos', 'bread', {'title': 'Bread', 'done': true});
await bob.merge(await alice.changeset('todos'));
await alice.merge(await bob.changeset('todos'));
print(await alice.value('todos', 'bread')); // {title: Bread, done: true}
print(await bob.value('todos', 'milk')); // {title: Milk, done: false}
}