timcreatedit / scribble

Scribble is a lightweight library for freehand drawing in Flutter supporting pressure, variable line width and more!
https://pub.dev/packages/scribble
MIT License
115 stars 39 forks source link

Can I add a listener when the drawing is added at onPointerUp? #36

Closed 2p31-1 closed 1 year ago

2p31-1 commented 1 year ago

I'm doing a project using several canvases in a screen. I wonder that it is possible to revert or redo the drawing with just a button on several scribble widgets.

Here is the scenario I am expecting:

  1. Scribble widgets are in various sized (they're resizable)

    제목 없음-2
  2. Drawing lines

    2 3
  3. revert with one button. The stack inside stores the orders of the scribbleNotifier which did drawing or erasing.

    4
  4. reverted in reverse order.

    5
timcreatedit commented 1 year ago

Hey there! Thanks for the extensive issue! scribble uses history_state_notifier internally for the undo/redo functionality. I would suggest you build your own extension of a HistoryStateNotifierMixin that allows for combining multiple StateNotifiers together and manage a shared undo/redo state. Since your usecase is very specific, I don't think this is within the scope of this package, but I'm happy to assist you. I will think about adding it to history_state_notifier, because I think it could be a worthwhile addition to that package (which would also trickle down to scribble), so feel free to open the issue on that repo again!