revert method

void revert(
  1. dynamic object,
  2. String property
)

Implementation

void revert(dynamic object, String property) {
  // local function

  bool applies(Command command) {
    if ( command is PropertyChangeCommand) {
      if (identical(command.target, object) && command.property == property)
        return true;
    }

    return false;
  }

  var wasDirty = isDirty();

  // undo the first command

  _stack.firstWhere(applies).undo(deleteOnly: true);

  // get rid of the rest

  for (var i = _stack.length - 1; i >= 0; i--)
    if ( applies(_stack[i])) {
      _stack.removeAt(i);
    }

  // did we change out state?

  _changeDirty(wasDirty);
}