PainterController class
Controller used to control a FlutterPainter widget.
- IMPORTANT: * Each FlutterPainter should have its own controller.
- Inheritance
-
- Object
- ChangeNotifier
- ValueNotifier<
PainterControllerValue> - PainterController
- 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
- 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
-
events
→ Stream<
PainterEvent> -
The stream of
PainterEvent
s dispatched from this controller.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
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
- selectedObjectDrawable → ObjectDrawable?
-
The currently selected object drawable.
no setter
- 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
-
addDrawables(
Iterable< Drawable> drawables, {bool newAction = true}) → void -
Add the
drawables
to the controller value drawables. -
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
-
addText(
) → void -
Dispatches a
AddTextPainterEvent
onevents
stream. -
clearDrawables(
{bool newAction = true}) → void - Removes all drawables from the controller value.
-
deselectObjectDrawable(
{bool isRemoved = false}) → void - Deselects the object drawable from the drawables.
-
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
-
groupDrawables(
{bool newAction = true}) → void - Groups all drawables in the controller into one drawable.
-
insertDrawables(
int index, Iterable< Drawable> drawables, {bool newAction = true}) → void -
Inserts the
drawables
to the controller value drawables at the providedindex
. -
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
-
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
withnewDrawable
in the controller value. -
selectObjectDrawable(
ObjectDrawable? drawable) → void - Selects an object drawable from the list of drawables.
-
toString(
) → String -
A string representation of this object.
inherited
-
undo(
) → void - Undoes the last action performed on drawables. The action can later be redone.
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.