Skip to content

ChangeStack

Change stack is a way to track the signal values overtime and undo or redo values.

final s = ChangeStackSignal(0, limit: 5);
s.value = 1;
s.value = 2;
s.value = 3;
print(s.value); // 3
s.undo();
print(s.value); // 2
s.redo();
print(s.value); // 3

Clear the undo/redo stack.

Returns true if there are changes in the undo stack and can move backward.

Returns true if there are changes in the redo stack and can move forward.

There is an optional limit that can be set for explicit stack size.

final s = ChangeStackSignal(0, limit: 2);
s.value = 1;
s.value = 2;
s.value = 3;
print(s.value); // 3
s.undo();
s.undo();
print(s.value); // 1
print(s.canUndo); // false
s.redo();
print(s.value); // 2