PainterController class

Controller used to control a FlutterPainter widget.

Inheritance
Available extensions

Constructors

PainterController({PainterSettings settings = const PainterSettings(), List<Drawable>? drawables = const [], BackgroundDrawable? background})
Create a PainterController.
PainterController.fromValue(PainterControllerValue value)
Create a PainterController from a PainterControllerValue.

Properties

background BackgroundDrawable?
Setting this will notify all the listeners of this PainterController that they need to update (it calls notifyListeners). For this reason, this value should only be set between frames, e.g. in response to user actions, not during the build, layout, or paint phases.
no getter
background BackgroundDrawable?

Available on PainterController, provided by the PainterControllerHelper extension

The current background drawable directly from value.
getter/setter pair
canRedo bool
Whether a redo operation can be performed or not.
no setter
canUndo bool
Whether an undo operation can be performed or not.
no setter
drawables List<Drawable>

Available on PainterController, provided by the PainterControllerHelper extension

The unmodifiable list of drawables directly from value.
no setter
drawShapeOnce bool

Available on PainterController, provided by the PainterControllerHelper extension

Whether to draw shapes once or continuously from value.settings.shape directly.
getter/setter pair
enlargeObjectControlsResolver ObjectEnlargeControlsResolver

Available on PainterController, provided by the PainterControllerHelper extension

The function used to decide whether to enlarge the object controls or not from value.settings.object directly.
getter/setter pair
events Stream<PainterEvent>
The stream of PainterEvents dispatched from this controller.
no setter
fillTolerance int

Available on PainterController, provided by the PainterControllerHelper extension

The tolerance percentage used by flood fills.
getter/setter pair
freeStyleColor Color

Available on PainterController, provided by the PainterControllerHelper extension

The color used for free-style drawing from value.settings.freeStyle directly.
getter/setter pair
freeStyleFactory FreeStyleFactory<PathDrawable>?

Available on PainterController, provided by the PainterControllerHelper extension

The factory used to create custom free-style drawables.
getter/setter pair
freeStyleMode FreeStyleMode

Available on PainterController, provided by the PainterControllerHelper extension

The free-style painting mode from value.settings.freeStyle directly.
getter/setter pair
freeStyleSettings FreeStyleSettings

Available on PainterController, provided by the PainterControllerHelper extension

The free-style settings directly from the painter settings.
getter/setter pair
freeStyleStrokeWidth double

Available on PainterController, provided by the PainterControllerHelper extension

The stroke width used for free-style drawing from value.settings.freeStyle directly.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
imageDrawableCountsByTag Map<String, int>

Available on PainterController, provided by the PainterControllerHelper extension

Counts tagged image drawables by their application-defined tag.
no setter
maxScale double

Available on PainterController, provided by the PainterControllerHelper extension

The maximum scale that the user can "zoom in" to from value.settings.scale directly.
getter/setter pair
minScale double

Available on PainterController, provided by the PainterControllerHelper extension

The minimum scale that the user can "zoom out" to from value.settings.scale directly.
getter/setter pair
objectLayoutAssist ObjectLayoutAssistSettings

Available on PainterController, provided by the PainterControllerHelper extension

The layout-assist settings of the selected object drawable from value.settings.object directly.
getter/setter pair
objectSettings ObjectSettings

Available on PainterController, provided by the PainterControllerHelper extension

The object settings directly from the painter settings.
getter/setter pair
painterKey GlobalKey<State<StatefulWidget>>
This key will be used by the FlutterPainter widget assigned this controller.
final
performedActions Queue<ControllerAction>
Queues used to track the actions performed on drawables in the controller. This is used to undo and redo actions.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scaleSettings ScaleSettings

Available on PainterController, provided by the PainterControllerHelper extension

The scale settings directly from the painter settings.
getter/setter pair
scalingEnabled bool

Available on PainterController, provided by the PainterControllerHelper extension

Whether scaling is enabled or not from value.settings.scale directly.
getter/setter pair
selectedObjectDrawable ObjectDrawable?
The currently selected object drawable.
no setter
settings PainterSettings

Available on PainterController, provided by the PainterControllerHelper extension

The current painter settings directly from value.
getter/setter pair
shapeFactory ShapeFactory<ShapeDrawable>?

Available on PainterController, provided by the PainterControllerHelper extension

The factory for the shape to be drawn from value.settings.shape directly.
getter/setter pair
shapePaint Paint?

Available on PainterController, provided by the PainterControllerHelper extension

The paint used to draw shapes from value.settings.shape directly.
getter/setter pair
shapeSettings ShapeSettings

Available on PainterController, provided by the PainterControllerHelper extension

The shape settings directly from the painter settings.
getter/setter pair
showObjectScaleRotationControlsResolver ObjectEnlargeControlsResolver

Available on PainterController, provided by the PainterControllerHelper extension

The function used to decide whether to show scale and rotation object controls or not from value.settings.object directly.
getter/setter pair
textAlign TextAlign

Available on PainterController, provided by the PainterControllerHelper extension

The alignment used for text drawables from value.settings.text directly.
getter/setter pair
textFocusNode FocusNode?

Available on PainterController, provided by the PainterControllerHelper extension

The focus node used to edit text drawables text from value.settings.text directly.
getter/setter pair
textSettings TextSettings

Available on PainterController, provided by the PainterControllerHelper extension

The text settings directly from the painter settings.
getter/setter pair
textStyle TextStyle

Available on PainterController, provided by the PainterControllerHelper extension

The text style to be used for text drawables from value.settings.text directly.
getter/setter pair
transformationController TransformationController
This controller will be used by the InteractiveViewer in FlutterPainter to notify children widgets of transformation changes.
final
unperformedActions Queue<ControllerAction>
Queues used to track the actions performed on drawables in the controller. This is used to undo and redo actions.
getter/setter pair
value PainterControllerValue
The current value stored in this notifier.
getter/setter pairinherited

Methods

addBlurredImage(Image image, Rect sourceRect, {Offset? position, Size? size, double blurSigma = 12, ImageDrawableShape shape = ImageDrawableShape.rectangle}) → void
Adds a blurred source-image region as a movable rectangle or oval.
addCroppedImage(Image image, Rect sourceRect, [Size? size]) → void
Adds a cropped ImageDrawable to the center of the painter.
addDrawables(Iterable<Drawable> drawables, {bool newAction = true}) → void
Add the drawables to the controller value drawables.
addFloodFill(Offset position, {Color? color, int? tolerance, Size? size, int maxPixels = defaultMaxFloodFillPixels}) Future<FloodFillDrawable?>
Creates and adds a flood fill as one undoable controller action.
addImage(Image image, [Size? size]) → void
Adds an ImageDrawable to the center of the painter.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addTaggedImage(Image image, {required String tag, Size? size, Rect? sourceRect}) → void
Adds a tagged ImageDrawable to the center of the painter.
addText() → void
Dispatches a AddTextPainterEvent on events stream.
addWidgetSnapshot(GlobalKey<State<StatefulWidget>> repaintBoundaryKey, {double? pixelRatio, Size? size, Offset? position, String? tag, bool erasable = true}) Future<ImageDrawable>
Captures a rendered widget and adds it as an editable ImageDrawable.
clearDrawables({bool newAction = true}) → void
Removes all drawables from the controller value.
createFloodFill(Offset position, {Color? color, int? tolerance, Size? size, int maxPixels = defaultMaxFloodFillPixels}) Future<FloodFillDrawable?>
Samples the composed painter and creates a connected flood-fill region.
cropImageDrawable(ImageDrawable drawable, Rect sourceRect, {bool newAction = true}) bool
Crops an existing drawable to sourceRect.
deselectObjectDrawable({bool isRemoved = false}) → void
Deselects the object drawable from the drawables.
dispose() → void
Discards any resources used by the object.
override
editTextDrawable(TextDrawable drawable) → void
Selects drawable and opens it in the attached painter's text editor.
groupDrawables({bool newAction = true}) → void
Groups all drawables in the controller into one drawable.
groupErasableDrawables({bool newAction = true}) → void
Groups only drawables that can be erased.
groupObjectDrawables(Iterable<ObjectDrawable> drawables, {bool selectGroup = true, bool newAction = true}) ObjectGroupDrawable?
Groups drawables into one selectable, transformable object.
insertDrawables(int index, Iterable<Drawable> drawables, {bool newAction = true}) → void
Inserts the drawables to the controller value drawables at the provided index.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void
Redoes the last undone action. The redo operation can be undone.
removeDrawable(Drawable drawable, {bool newAction = true}) bool
Removes the first occurrence of drawable from the controller value.
removeLastDrawable({bool newAction = true}) → void
Removes the last drawable from the controller value.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeSelectedObjectDrawable({bool newAction = true}) bool
Removes the currently selected object drawable.
renderImage(Size size) Future<Image>
Renders the background and all other drawables to a ui.Image object.
replaceDrawable(Drawable oldDrawable, Drawable newDrawable, {bool newAction = true}) bool
Replace oldDrawable with newDrawable in the controller value.
selectObjectDrawable(ObjectDrawable? drawable) → void
Selects an object drawable from the list of drawables.
setAngleDegrees(AngleDrawable drawable, double degrees, {bool newAction = true}) bool

Available on PainterController, provided by the PainterControllerHelper extension

Replaces drawable with a copy using a clockwise sweep in degrees.
setDrawableColor(Drawable drawable, Color color, {bool newAction = true}) bool

Available on PainterController, provided by the PainterControllerHelper extension

Replaces a color-bearing drawable with a copy using color.
setShapeLabel(LabeledShapeDrawable drawable, ShapeLabel label, {bool newAction = true}) bool

Available on PainterController, provided by the PainterControllerHelper extension

Replaces the label on a labeled shape.
toString() String
A string representation of this object.
inherited
undo() → void
Undoes the last action performed on drawables. The action can later be redone.
ungroupObjectDrawable(ObjectGroupDrawable group, {bool newAction = true}) List<ObjectDrawable>?
Replaces group with its transformed child objects.
ungroupSelectedObjectDrawable({bool newAction = true}) List<ObjectDrawable>?
Ungroups the currently selected object when it is a group.

Operators

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

Static Methods

of(BuildContext context) PainterController
Uses the PainterControllerWidget inherited widget to fetch the PainterController instance in this context. This is used internally in the library to fetch the controller at different widgets.

Constants

defaultMaxFloodFillPixels → const int
Default upper bound for the sampled flood-fill raster.