PainterController class

Controller class for managing painter-related functionalities. This class handles state management, drawing operations, erasing, adding text or images, and other actions for a painting application.

Inheritance
Available extensions

Constructors

PainterController({PainterSettings settings = const PainterSettings(), Uint8List? backgroundImage})
Constructor to initialize the controller with default or custom settings.
PainterController.fromValue(PainterControllerValue value, {Uint8List? backgroundImage})
Alternate constructor that initializes the controller with a specific value and optional background image.

Properties

addingText bool
getter/setter pair
background ↔ PainterBackground
Background object for handling the painting canvas background.
getter/setter pair
cacheBackgroundImage Image?
Cached image of the background for performance improvements.
getter/setter pair
changeActions ValueNotifier<PaintActions>
ValueNotifier to track changes in paint actions.
getter/setter pair
editingText bool
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isDrawing bool
getter/setter pair
isErasing bool
Flags to determine the current state of the painter (drawing, erasing, etc.).
getter/setter pair
itemRender ↔ RenderItem
Rendered image of the painter content.
getter/setter pair
repaintBoundaryKey GlobalKey<State<StatefulWidget>>
GlobalKey used to identify the repaint boundary for rendering images.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value PainterControllerValue
The current value stored in this notifier.
getter/setter pairinherited

Methods

addAction(PaintAction action) → void

Available on PainterController, provided by the PainterControllerActions extension

Adds an action to the action history and updates the current change actions.
addCustomWidget(Widget widget, {String? layerTitle}) → void

Available on PainterController, provided by the PainterControllerItemCustomWidget extension

Adds an image to the painter as a new item, using the provided Uint8List. The image is inserted at the top of the items list, and an action is logged.
addImage(Uint8List image, {String? layerTitle}) → void

Available on PainterController, provided by the PainterControllerItemImage extension

Adds an image to the painter as a new item, using the provided Uint8List. The image is inserted at the top of the items list, and an action is logged.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addPaintPoint(DrawModel point) → void

Available on PainterController, provided by the PainterControllerPaint extension

Adds a paint point to the current drawing path or performs erasing if the eraser mode is enabled.
addShape(ShapeType shapeType, {String? layerTitle}) → void

Available on PainterController, provided by the PainterControllerItemShape extension

addText(String text, {String? layerTitle}) Future<void>

Available on PainterController, provided by the PainterControllerItemText extension

Adds a text item to the painting canvas.
changeBrushValues({double? size, Color? color}) → void

Available on PainterController, provided by the PainterControllerPaintValues extension

changeCustomWidgetValues(CustomWidgetItem item, {Widget? widget, BorderRadius? borderRadius, Color? borderColor, double? borderWidth, bool? enableGradientColor, Color? gradientStartColor, Color? gradientEndColor, AlignmentGeometry? gradientBegin, AlignmentGeometry? gradientEnd, double? gradientOpacity}) → void

Available on PainterController, provided by the PainterControllerItemCustomWidgetValues extension

changeEraseValues({double? size, Color? color}) → void

Available on PainterController, provided by the PainterControllerPaintValues extension

changeImageValues(ImageItem item, {BoxFit? boxFit, BorderRadius? borderRadius, Color? borderColor, double? borderWidth, bool? enableGradientColor, Color? gradientStartColor, Color? gradientEndColor, AlignmentGeometry? gradientBegin, AlignmentGeometry? gradientEnd, double? gradientOpacity}) → void

Available on PainterController, provided by the PainterControllerItemImageValues extension

changeItemProperties(PainterItem item, {PositionModel? position, double? rotation, SizeModel? size}) → void

Available on PainterController, provided by the PainterControllerItemProperties extension

changeShapeValues(ShapeItem item, {ShapeType? shapeType, Color? backgroundColor, Color? lineColor, double? thickness}) → void

Available on PainterController, provided by the PainterControllerItemShapeValues extension

changeTextValues(TextItem item, {TextStyle? textStyle, TextAlign? textAlign, bool? enableGradientColor, Color? gradientStartColor, Color? gradientEndColor, AlignmentGeometry? gradientBegin, AlignmentGeometry? gradientEnd}) → void

Available on PainterController, provided by the PainterControllerItemTextValues extension

clearSelectedItem() → void

Available on PainterController, provided by the PainterControllerItems extension

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
endPath() → void

Available on PainterController, provided by the PainterControllerPaint extension

Ends the current drawing or erasing path, updating the state accordingly.
eventListener(void onData(ControllerEvent)) StreamSubscription<ControllerEvent>

Available on PainterController, provided by the PainterControllerMain extension

Listens to events triggered by the controller and executes the provided callback. Returns a subscription that can be used to manage the listener.
getLayerIndex(PainterItem item) int

Available on PainterController, provided by the PainterControllerLayer extension

Retrieves the layer index of the specified item.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void

Available on PainterController, provided by the PainterControllerActions extension

refreshValue() → void

Available on PainterController, provided by the PainterControllerMain extension

removeItem({int? layerIndex}) → void

Available on PainterController, provided by the PainterControllerItems extension

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}) Future<Uint8List?>

Available on PainterController, provided by the PainterControllerRender extension

Renders the current painting as an image and returns it as a Uint8List. This can be used to save or share the painted content.
renderItem(PainterItem item, {bool enableRotation = false}) Future<Uint8List?>

Available on PainterController, provided by the PainterControllerRender extension

setBackgroundImage(Uint8List? imageData) Future<void>

Available on PainterController, provided by the PainterControllerMain extension

Sets a background image for the painter.
setItemPosition(int index, PositionModel position) → void

Available on PainterController, provided by the PainterControllerItems extension

Updates the position of an item in the items list at the specified index.
setItemRotation(int index, double rotation) → void

Available on PainterController, provided by the PainterControllerItems extension

Updates the rotation of an item in the items list at the specified index.
setItemSize(int index, SizeModel size) → void

Available on PainterController, provided by the PainterControllerItems extension

Updates the size of an item in the items list at the specified index.
toggleDrawing() → void

Available on PainterController, provided by the PainterControllerPaint extension

Toggles the drawing mode. If enabled, disables the erasing mode.
toggleErasing() → void

Available on PainterController, provided by the PainterControllerPaint extension

Toggles the erasing mode. If enabled, disables the drawing mode.
toString() String
A string representation of this object.
inherited
triggerEvent(ControllerEvent event) → void

Available on PainterController, provided by the PainterControllerMain extension

Triggers an event for all listeners of the event stream.
undo() → void

Available on PainterController, provided by the PainterControllerActions extension

updateActionWithChangeActionIndex(int index) → void

Available on PainterController, provided by the PainterControllerActions extension

updateLayerIndex(PainterItem item, int newIndex) → void

Available on PainterController, provided by the PainterControllerLayer extension

Operators

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