Delta class

Delta represents a document or a modification of a document as a sequence of insert, delete and retain operations.

Delta consisting of only "insert" operations is usually referred to as "document delta". When delta includes also "retain" or "delete" operations it is a "change delta".

Constructors

Delta()
Creates new empty Delta.
factory
Delta.from(Delta other)
Creates new Delta from other.
factory
Delta.fromOperations(List<Operation> operations)
Creates new Delta from a List of Operation
factory

Properties

first → Operation
Returns the first Operation in this delta.
no setter
hashCode → int
The hash code for this object.
no setteroverride
isEmpty → bool
Returns true if this delta is empty.
no setter
isNotEmpty → bool
Returns true if this delta is not empty.
no setter
last → Operation
Returns the last Operation in this delta.
no setter
length → int
Returns number of operations in this delta.
no setter
modificationCount ↔ int
getter/setter pair
operations → List<Operation>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

compose(Delta other) → Delta
Composes this delta with other and returns new Delta.
concat(Delta other, {bool trimNewLine = false}) → Delta
Concatenates other with this delta and returns the result.
delete(int count) → void
Delete count characters from current position.
diff(Delta other, {bool cleanupSemantic = true}) → Delta
Returns a Delta containing differences between 2 Deltas. If cleanupSemantic is true (default), applies the following:
elementAt(int index) → Operation
Returns Operation at specified index in this delta.
insert(dynamic data, [Map<String, dynamic>? attributes]) → void
Insert data at current position.
invert(Delta base) → Delta
Inverts this delta against base.
map<T>(T f(Operation)) → Iterable<T>
Returns a new lazy Iterable with elements that are created by calling f on each element of this Iterable in iteration order.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
push(Operation operation) → void
Pushes new operation into this delta.
retain(int count, [Map<String, dynamic>? attributes]) → void
Retain count of characters from current position.
slice(int start, [int? end]) → Delta
Returns slice of this delta from start index (inclusive) to end (exclusive).
toJson() → List<Map<String, dynamic>>
Returns JSON-serializable version of this delta.
toList() → List<Operation>
Returns list of operations in this delta.
toString() → String
A string representation of this object.
override
transform(Delta other, bool priority) → Delta
Transforms other delta against operations in this delta.
transformPosition(int index, {bool force = true}) → int
Transforms index against this delta.
trim() → void
Removes trailing retain operation with empty attributes, if present.

Operators

operator ==(Object other) → bool
The equality operator.
override
operator [](int index) → Operation
Returns Operation at specified index in this delta.

Static Methods

composeAttributes(Map<String, dynamic>? a, Map<String, dynamic>? b, {bool keepNull = false}) → Map<String, dynamic>?
Composes two attribute sets.
diffAttributes(Map<String, dynamic>? a, Map<String, dynamic>? b) → Map<String, dynamic>?
Returns diff between two attribute sets
fromJson(List data, {DataDecoder? dataDecoder}) → Delta
Creates Delta from de-serialized JSON representation.
invertAttributes(Map<String, dynamic>? attr, Map<String, dynamic>? base) → Map<String, dynamic>
get anti-attr result base on base
transformAttributes(Map<String, dynamic>? a, Map<String, dynamic>? b, bool priority) → Map<String, dynamic>?
Transforms two attribute sets.