SketchBoard class

SketchBoard is the main widget that renders a drawable canvas.

It supports two modes:

  • Draw Mode: where the user can draw handwriting directly on the canvas.
  • Move Mode: where the canvas can be zoomed and panned.

Features:

  • Renders handwriting using the Sketchcontroller.
  • Supports zoom and pan using InteractiveViewer.
  • Accepts overlay widgets (e.g., images or decorations) via overlayWidgets.
  • Wraps everything in a RepaintBoundary to support images export.

controller: Required controller that holds the drawing state. repaintKey: Key used to extract the widget as an images (PNG). overlayWidgets: Visual widgets (images, decorations, etc.) to be rendered below the drawing. boardColor: Background color of the drawing area. boardMinScale, boardMaxScale: Zoom scale limits when in move mode. backgroundColor: Scaffold background (outside the canvas). isPadDevice: Enable palm rejection by separating stylus and touch input.

Note:

  • All content, including overlay widgets and the canvas, will be captured when exporting as an images.
Inheritance

Constructors

SketchBoard({Key? key, required SketchController controller, GlobalKey<State<StatefulWidget>>? repaintKey, Color? boardColor, double? boardMaxScale, double? boardMinScale, Color? backgroundColor, Widget? overlayWidget, double? boardWidthSize, double? boardHeightSize, bool isPadDevice = false, bool multiTouchPanZoomEnabled = false})
Main widget for the sketch board.
const

Properties

backgroundColor Color?
final
boardColor Color?
final
boardHeightSize double?
final
boardMaxScale double?
final
boardMinScale double?
final
boardWidthSize double?
final
controller SketchController
final
hashCode int
The hash code for this object.
no setterinherited
isPadDevice bool
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
multiTouchPanZoomEnabled bool
final
overlayWidget Widget?
final
repaintKey GlobalKey<State<StatefulWidget>>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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