Skip to content

ChangeStackSignalMixin

ChangeStackSignalMixin is a mixin for a Signal that adds undo and redo functionality.

class MySignal extends Signal<int> with ChangeStackSignalMixin<int> {
MySignal(int value) : super(value);
}
void main() {
final signal = MySignal(0);
signal.value = 1;
print(signal.canUndo); // true
signal.undo();
print(signal.value); // 0
print(signal.canUndo); // false
signal.redo();
print(signal.value); // 1
}

Setting a limit

You can set a limit to the number of changes that can be undone with the limit parameter.

class MySignal extends Signal<int> with ChangeStackSignalMixin<int> {
MySignal(int value) : super(value);
@override
int limit = 3;
}