ListChangeRecord class
A change record for an observable list.
class ListChangeRecord extends ChangeRecord { /** The starting index of the change. */ final int index; /** The number of items removed. */ final int removedCount; /** The number of items added. */ final int addedCount; ListChangeRecord(this.index, {this.removedCount: 0, this.addedCount: 0}) { if (addedCount == 0 && removedCount == 0) { throw new ArgumentError('added and removed counts should not both be ' 'zero. Use 1 if this was a single item update.'); } } /** Returns true if the provided index was changed by this operation. */ bool changes(key) { // If key isn't an int, or before the index, then it wasn't changed. if (key is! int || key < index) return false; // If this was a shift operation, anything after index is changed. if (addedCount != removedCount) return true; // Otherwise, anything in the update range was changed. return key < index + addedCount; } String toString() => '#<ListChangeRecord index: $index, ' 'removed: $removedCount, addedCount: $addedCount>'; }
Extends
ChangeRecord > ListChangeRecord
Constructors
new ListChangeRecord(int index, {int removedCount: 0, int addedCount: 0}) #
ListChangeRecord(this.index, {this.removedCount: 0, this.addedCount: 0}) { if (addedCount == 0 && removedCount == 0) { throw new ArgumentError('added and removed counts should not both be ' 'zero. Use 1 if this was a single item update.'); } }
Properties
final int addedCount #
The number of items added.
final int addedCount
final int index #
The starting index of the change.
final int index
final int removedCount #
The number of items removed.
final int removedCount
Methods
abstract bool change(key) #
inherited from ChangeRecord
True if the change affected the given item, otherwise false.
bool changes(key) #
Returns true if the provided index was changed by this operation.
bool changes(key) { // If key isn't an int, or before the index, then it wasn't changed. if (key is! int || key < index) return false; // If this was a shift operation, anything after index is changed. if (addedCount != removedCount) return true; // Otherwise, anything in the update range was changed. return key < index + addedCount; }
String toString() #
Returns a string representation of this object.
docs inherited from Object
String toString() => '#<ListChangeRecord index: $index, ' 'removed: $removedCount, addedCount: $addedCount>';