ScribbleNotifier class

The default implementation of a ScribbleNotifierBase.

This class controls the state and behavior for a Scribble widget.

Inheritance

Constructors

ScribbleNotifier({Sketch? sketch, ScribblePointerMode allowedPointersMode = ScribblePointerMode.all, int maxHistoryLength = 30, List<double> widths = const [5, 10, 15], Curve pressureCurve = Curves.linear})
The default implementation of a ScribbleNotifierBase.

Properties

allowOperations bool
You can override this to prevent undo/redo operations in certain cases (e.g. when in a loading value)
no setterinherited
canRedo bool
Whether a redo operation is currently possible.
no setterinherited
canUndo bool
Whether currently an undo operation is possible.
no setterinherited
currentSketch Sketch
The state of the sketch at this moment.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
includeInitialValueInHistory bool
Whether to include the initial value in the undo history.
no setterinherited
maxHistoryLength int?
How many values to keep track of.
getter/setter pairinherited
pressureCurve Curve
The curve that's used to map pen pressure to the pressure value when recording.
final
repaintBoundaryKey GlobalKey<State<StatefulWidget>>
You need to provide a key that the RepaintBoundary can use so you can access it from the renderImage method.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
temporaryValue ScribbleState
Sets the current "value" of this HistoryValueNotifier without adding the new value to the undo history.
no getterinherited
value ScribbleState
The current value stored in this notifier.
getter/setter pairinherited
widths List<double>
The supported widths, mainly useful for rendering UI, you can still set the width to any arbitrary value from code.
final

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
clear() → void
Clear the entire drawing.
clearQueue() → void
Removes all history items from the queue.
inherited
clearRedoQueue() → void
Removes all history items that happened after the current undo position.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onPointerCancel(PointerCancelEvent event) → void
Used by the Listener callback to stop displaying the cursor
override
onPointerDown(PointerDownEvent event) → void
Used by the Listener callback to start drawing
override
onPointerExit(PointerExitEvent event) → void
Should be called when the pointer exits the canvas with the corresponding event.
override
onPointerHover(PointerHoverEvent event) → void
Used by the Listener callback to display the pen if desired
override
onPointerUp(PointerUpEvent event) → void
Used by the Listener callback to finish a line
override
onPointerUpdate(PointerMoveEvent event) → void
Used by the Listener callback to update the drawing
override
redo() → void
Proceeds to the next value in the history.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
renderImage({double pixelRatio = 1.0, ImageByteFormat format = ui.ImageByteFormat.png}) Future<ByteData>
Used to render the image to ByteData which can then be stored or reused for example in an Image.memory widget.
inherited
setAllowedPointersMode(ScribblePointerMode allowedPointersMode) → void
Sets the current mode of allowed pointers to the given ScribblePointerMode
setColor(Color color) → void
Sets the color of the pen to the given color.
setEraser() → void
Switches to eraser mode
setScaleFactor(double factor) → void
Sets the zoom factor to allow for adjusting line width.
setSketch({required Sketch sketch, bool addToUndoHistory = true}) → void
Can be used to update the state of the Sketch externally (e.g. when fetching from a server) to what is passed in as sketch;
setStrokeWidth(double strokeWidth) → void
Sets the width of the next line
shouldInsertValueIntoQueue(ScribbleState newValue, ScribbleState lastInQueue) bool
You can override this function if you want to filter certain values before adding them to the history.
inherited
toString() String
A string representation of this object.
inherited
transformHistoryValue(ScribbleState historyValue, ScribbleState currentState) ScribbleState
Only apply the sketch from the undo history, otherwise keep current state
undo() → void
Returns to the previous value in the history.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited