undoRedo<T> static method

UndoRedoBeacon<T> undoRedo<T>(
  1. T initialValue, {
  2. int historyLimit = 10,
})

Creates an UndoRedoBeacon with an initial value and an optional history limit. This beacon allows undoing and redoing changes to its value, up to the specified number of past states.

This beacon is particularly useful in scenarios where you need to provide undo/redo functionality, such as in text editors or form input fields.

Example:

var undoRedoBeacon = UndoRedoBeacon<int>(0, historyLimit: 10);
undoRedoBeacon.value = 10;
undoRedoBeacon.value = 20;
undoRedoBeacon.undo(); // Reverts to 10
undoRedoBeacon.redo(); // Goes back to 20

Implementation

static UndoRedoBeacon<T> undoRedo<T>(
  T initialValue, {
  int historyLimit = 10,
}) {
  return UndoRedoBeacon<T>(
    initialValue: initialValue,
    historyLimit: historyLimit,
  );
}