LazyCanvasController class
Controller for LazyCanvas
- Mixed-in types
Constructors
- LazyCanvasController({double? minScale, double? maxScale, bool debug = false, double buildExtentMultiplier = 2, Size hashCellSize = const Size(100, 100), Duration defaultAnimationDuration = const Duration(milliseconds: 300), bool inertiaEnabled = true, double inertiaFrictionCoefficient = 0.0000135, CanvasBackground background = const DotGridBackground(), bool useIdsFromArgs = false, OnWidgetEnteredRender? onWidgetEnteredRender, OnWidgetExitedRender? onWidgetExitedRender, PointerSignalEventListener? rawPointerSignalListener, PointerDownEventListener? rawPointerDownListener, PointerMoveEventListener? rawPointerMoveListener, PointerUpEventListener? rawPointerUpListener, PointerCancelEventListener? rawPointerCancelListener})
- Supplied zoom limits must be finite, positive, and ordered. The initial scale of 1 is clamped to these limits.
Properties
- background ↔ CanvasBackground
-
getter/setter pair
- buildExtent → Offset
-
no setter
- buildExtentMultiplier → double
-
final
- canvasSize → Size
-
no setter
-
childOrder
→ List<
CanvasChildId> -
Immutable back-to-front snapshot of all children, including culled children.
no setter
- debug ↔ bool
-
getter/setter pair
- defaultAnimationDuration → Duration
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- inertiaEnabled → bool
-
final
- inertiaFrictionCoefficient → double
-
final
- maxScale → double?
-
Maximum zoom scale, or null for no upper limit.
final
- minScale → double?
-
Minimum zoom scale, or null for no lower limit.
final
- offset → Offset
-
no setter
- onWidgetEnteredRender ↔ OnWidgetEnteredRender?
-
getter/setter pair
- onWidgetExitedRender ↔ OnWidgetEnteredRender?
-
getter/setter pair
- rawPointerCancelListener ↔ PointerCancelEventListener?
-
getter/setter pair
- rawPointerDownListener ↔ PointerDownEventListener?
-
getter/setter pair
- rawPointerMoveListener ↔ PointerMoveEventListener?
-
getter/setter pair
- rawPointerSignalListener ↔ PointerSignalEventListener?
-
getter/setter pair
- rawPointerUpListener ↔ PointerUpEventListener?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double
-
no setter
- useIdsFromArgs → bool
-
final
Methods
-
addChild(
Offset position, Widget widget, {Size? childSize, double rotation = 0, CanvasChildId? id}) → CanvasChildId -
Add a child at a given position with a widget. Returns the child ID.
You need the child size for optimising the focus on child
rotationis clockwise radians around the layout center. -
addChildren(
List< CanvasChildArgs> children, {CanvasChildId? focusOnBuild}) → List<CanvasChildId> -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
animateToOffsetAndScale(
{required Offset offset, required double scale, Duration? duration, Curve curve = Curves.easeInOut}) → Future< void> - Animate the canvas to a new offset and scale Clamps the target and animated scale to the zoom limits.
-
bringForward(
Iterable< CanvasChildId> ids) → bool - Moves the bundle above the nearest overlapping unselected child above it. Preserves target and non-target relative order; see canArrange for errors.
-
bringToFront(
Iterable< CanvasChildId> ids) → bool - Paints and hit tests the ordered bundle above all other children. Returns whether order changed; changed commands notify exactly once.
-
canArrange(
Iterable< CanvasChildId> ids, CanvasArrange action) → bool -
Checks whether
actionwould change order, without notifying or mutating. Targets are deduplicated and all IDs are validated, as in the commands. Forward/backward throw StateError if a required layout size is unknown. -
centerOnGridOffset(
Offset gsOffset, {Duration? duration, bool animate = true}) → void - Center the canvas so that the given grid-space offset is at the center of the viewport.
-
centerOnScreenOffset(
Offset ssOffset, {Duration? duration, bool animate = true}) → void - Center the canvas so that the given screen-space offset is at the center of the viewport.
-
clear(
) → void - Remove all children. Does not change where you are on the canvas.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
focusOnChild(
CanvasChildId id, {ScalingMode scalingMode = ScalingMode.keepScale, bool animate = true, double preferredHorizontalMargin = 16, Duration? duration, Size? childSize, dynamic forceRedraw = false}) → void - Focus the viewport on a child by its ID, with a margin in screen-space. If it's already rendered, size will be picked up from the child widget. If not an offstage rendering will be used ( double render ) Preferred horizontal margin used for ScalingMode.fitInViewport. Fits rotated bounds in both viewport dimensions and centers using the resulting scale. Zoom limits take precedence over fitting; the child remains centered.
-
getInfo(
CanvasChildId id) → ChildInfo - Read a snapshot without building or laying out the child.
-
hasChild(
CanvasChildId id) → bool - Returns true if the child exists, false otherwise.
-
markDirty(
) → void -
moveChildBy(
CanvasChildId id, Offset gridDelta) → CanvasChildId -
Move a child by
gridDeltain canvas coordinates. Returns the child ID. -
moveChildrenBy(
Iterable< CanvasChildId> ids, Offset gridDelta) → void - Move unique children together, validating every resulting position first.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onCanvasSizeChange(
Size size) → void - Update the canvas size when the widget size changes.
-
onChildSizeChange(
CanvasChildId id, Size size) → void - Called when a child widget's size changes.
-
onScaleEnd(
ScaleEndDetails details) → void - Called when a scale gesture ends.
-
onScaleStart(
ScaleStartDetails details) → void - Called when a scale gesture starts.
-
onScaleUpdate(
ScaleUpdateDetails details) → void - Called when a scale gesture updates. Usually you would not want to override this
-
removeChild(
CanvasChildId id) → void - Remove a child by its ID.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
scrollBy(
Offset screenDelta) → void - Scroll the viewport by a screen-space pointer delta.
-
sendBackward(
Iterable< CanvasChildId> ids) → bool - Moves the bundle below the nearest overlapping unselected child below it. Preserves target and non-target relative order; see canArrange for errors.
-
sendToBack(
Iterable< CanvasChildId> ids) → bool - Paints and hit tests the ordered bundle below all other children. Returns whether order changed; changed commands notify exactly once.
-
setBuildContext(
BuildContext context) → void -
setChildOrder(
List< CanvasChildId> ids) → void - Sets the complete back-to-front paint and hit-test order atomically. Every existing ID, including culled children, must appear exactly once. Throws ArgumentError for missing, duplicate, unknown, or excess IDs, leaving order unchanged without notifying. Changed orders notify once; unchanged orders (including an empty stack) do not notify.
-
setTickerProvider(
TickerProvider? ticker) → void - Set the ticker provider for animations.
-
stopAnimation(
) → void - Stops inertia or an animated viewport transition at its current position.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
CanvasChildId id, {Offset? position, double? rotation, Size? childSize, Widget? widget}) → bool -
Apply supplied fields atomically. Null fields leave existing values unchanged.
Returns whether anything changed; changed updates notify exactly once.
rotationis clockwise radians around the layout center. -
updateScalebyDelta(
double delta, {Offset? focalPoint}) → void - Increment or decrement the scale by an additive delta value. Clamps to the zoom limits while preserving the focal point.
-
widgetsWithScreenPositions(
{bool forceRebuild = false}) → List< ChildInfo> - Currently rendered widgets with their position info
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited