- Pure Dart
- Save changes on collection
dependencies:
isar_crdt: ^0.0.1
- extend your models with CrdtBaseObject
- add toJson function and add all the fields you want to sync (include id and sid)
- Create a model to store the crdt changes and extends with ChangesyncBaseModel
- no need to add anything
// models
@collection
class CarModel extends CrdtBaseObject {
Id id = Isar.autoIncrement;
late String make;
late String year;
@override
Map<String, dynamic> toJson() {
return {
"id": id,
"sid": sid,
"make": make,
"year": year,
};
}
}
@collection
class CrdtEntry extends ChangesyncBaseModel {}
- add the models including the crdt model to the isar instance
- create a changesync instance and add it to the isar instance
final isar = await Isar.open(
[CarModelSchema, CrdtEntrySchema],
);
final changesSync = IsarCrdt(
store: IsarMasterCrdtStore(
isar.crdtEntrys,
builder: () => CrdtEntry(),
sidGenerator: () => uuid.v4(),
),
);
isar.setCrdt(changesSync);
TODO: Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.