RgaText class
A convergent collaborative text CRDT for editors, built on RgaList.
var doc = RgaText(replicaId: 'device-a').insert(0, 'hello');
doc = doc.insert(5, ' world');
doc = doc.delete(0, 1).insert(0, 'H'); // 'Hello world'
// Another device edits concurrently, then both merge to the same string:
final merged = doc.merge(otherDeviceDoc);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- length → int
-
The text length.
no setter
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- replicaId → String
-
This replica's identity.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringify → bool?
-
If set to
true, thetoStringmethod will be overridden to output this instance'sprops.no setterinherited - tombstoneCount → int
-
Deletes
countcharacters starting atindex. Number of tombstoned characters retained for ordering (see compact).no setter - value → String
-
The current text.
no setteroverride
Methods
-
characterIdAt(
int index) → String -
A stable id for the character at
index(anchor for remote cursors). -
compact(
) → RgaText - Returns a copy with every tombstone purged — see RgaList.compacted for the coordination contract (compact only at a sync barrier). Character ids, and therefore cursor anchors, are preserved.
-
delete(
int index, int count) → RgaText -
indexOfCharacter(
String id) → int -
The current index of the character with
id, or -1 if deleted. -
insert(
int index, String text) → RgaText -
Inserts
textat characterindexas one contiguous, non-interleavable run. -
merge(
covariant RgaText other) → RgaText -
Merges this CRDT with another of the same type.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
Converts the CRDT state to a map for serialization.
override
-
toString(
) → String - A string representation of this object.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited