pub struct UndoHistory<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static = Ref<ValueNotifier<T>>> {
pub key: Option<KeyRef>,
pub should_change_undo_stack: Option<ShouldChangeUndoStack<T>>,
pub value: V,
pub on_triggered: UndoHistoryOnTriggered<T>,
pub focus_node: FocusNodeRef,
pub undo_stack_modifier: Option<UndoStackModifier<T>>,
pub controller: Option<Ref<UndoHistoryController>>,
pub child: WidgetRef,
}Expand description
Provides undo/redo capabilities for a ValueNotifier.
Listens to value and saves relevant values for undoing/redoing. The
cadence at which values are saved is a best approximation of the native
behaviors of a number of hardware keyboard on Flutter’s desktop
platforms, as there are subtle differences between each of the platforms.
Listens to keyboard undo/redo shortcuts and calls on_triggered when a
shortcut is triggered that would affect the state of the value.
The child must manage focus on the focus_node. For
example, using a TextField or Focus widget.
The value is any kept ValueListenable, which Dart types as a
ValueNotifier<T>: a Ref<ValueNotifier<T>>, or a TextEditingControllerRef.
Fields§
§key: Option<KeyRef>See Widget::key.
should_change_undo_stack: Option<ShouldChangeUndoStack<T>>Called when checking whether a value change should be pushed onto the undo stack.
value: VThe value to track over time.
on_triggered: UndoHistoryOnTriggered<T>Called when an undo or redo causes a state change.
If the state would still be the same before and after the undo/redo, this will not be called. For example, receiving a redo when there is nothing to redo will not call this method.
Changes to the value while this method is running will not be recorded
on the undo stack. For example, a TextInputFormatter may change the value
from what was on the undo stack, but this new value will not be recorded,
as that would wipe out the redo history.
focus_node: FocusNodeRefThe [FocusNode] that will be used to listen for focus to set the initial
undo state for the element.
undo_stack_modifier: Option<UndoStackModifier<T>>Called right before a new entry is pushed to the undo stack.
The value returned from this method will be pushed to the stack instead of the original value.
If null then the original value will always be pushed to the stack.
controller: Option<Ref<UndoHistoryController>>Controls the undo state.
If null, this widget will create its own UndoHistoryController.
child: WidgetRefThe child widget of UndoHistory.
Implementations§
Source§impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> UndoHistory<T, V>
impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> UndoHistory<T, V>
Sourcepub fn new<K>(
value: V,
on_triggered: impl Fn(&mut App, T) + 'static,
focus_node: FocusNodeRef,
child: impl IntoWidget<K>,
) -> UndoHistory<T, V>
pub fn new<K>( value: V, on_triggered: impl Fn(&mut App, T) + 'static, focus_node: FocusNodeRef, child: impl IntoWidget<K>, ) -> UndoHistory<T, V>
Creates an instance of UndoHistory.
Sourcepub fn key(self, key: KeyRef) -> UndoHistory<T, V>
pub fn key(self, key: KeyRef) -> UndoHistory<T, V>
Dart UndoHistory(key:).
Sourcepub fn should_change_undo_stack(
self,
should_change_undo_stack: impl Fn(Option<&T>, &T) -> bool + 'static,
) -> UndoHistory<T, V>
pub fn should_change_undo_stack( self, should_change_undo_stack: impl Fn(Option<&T>, &T) -> bool + 'static, ) -> UndoHistory<T, V>
Dart UndoHistory(shouldChangeUndoStack:).
Sourcepub fn undo_stack_modifier(
self,
undo_stack_modifier: impl Fn(T) -> T + 'static,
) -> UndoHistory<T, V>
pub fn undo_stack_modifier( self, undo_stack_modifier: impl Fn(T) -> T + 'static, ) -> UndoHistory<T, V>
Dart UndoHistory(undoStackModifier:).
Sourcepub fn controller(
self,
controller: Ref<UndoHistoryController>,
) -> UndoHistory<T, V>
pub fn controller( self, controller: Ref<UndoHistoryController>, ) -> UndoHistory<T, V>
Dart UndoHistory(controller:).
Trait Implementations§
Source§impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> Debug for UndoHistory<T, V>
impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> Debug for UndoHistory<T, V>
Source§impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> StatefulWidget for UndoHistory<T, V>
impl<T: Clone + PartialEq + 'static, V: ValueListenable<T> + Clone + PartialEq + 'static> StatefulWidget for UndoHistory<T, V>
Source§type State = UndoHistoryState<T, V>
type State = UndoHistoryState<T, V>
Source§fn create_state(&self) -> UndoHistoryState<T, V>
fn create_state(&self) -> UndoHistoryState<T, V>
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl<T, V = Retained<Handle<ValueNotifier<T>>>> !RefUnwindSafe for UndoHistory<T, V>
impl<T, V = Retained<Handle<ValueNotifier<T>>>> !Send for UndoHistory<T, V>
impl<T, V = Retained<Handle<ValueNotifier<T>>>> !Sync for UndoHistory<T, V>
impl<T, V = Retained<Handle<ValueNotifier<T>>>> !UnwindSafe for UndoHistory<T, V>
impl<T, V> Forget for UndoHistory<T, V>
impl<T, V> Freeze for UndoHistory<T, V>where
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Fn(Option<&T>, &T) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(Option<&T>, &T) -> bool>>: Freeze,
V: Freeze,
*const RcInner<dyn Fn(&mut App, T)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, T)>>: Freeze,
NonZero<u32>: Freeze,
&'static FocusNodeVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn Fn(T) -> T> is !null: Freeze,
PhantomData<RcInner<dyn Fn(T) -> T>>: Freeze,
PhantomData<fn() -> UndoHistoryController>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl<T, V> Move for UndoHistory<T, V>
impl<T, V> Unpin for UndoHistory<T, V>
impl<T, V> UnsafeUnpin for UndoHistory<T, V>where
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Fn(Option<&T>, &T) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(Option<&T>, &T) -> bool>>: UnsafeUnpin,
V: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, T)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, T)>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn Fn(T) -> T> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(T) -> T>>: UnsafeUnpin,
PhantomData<fn() -> UndoHistoryController>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.