DrawScreen class
Pushed tool screen for the draw editor. Borrows a DrawImageLayer
and an optional EntityLayer from the host (e.g. ComposeEntry);
on push they snapshot their state, on cancel they restore, on apply
they commit. Pops true on apply / false on cancel.
The transition is intentionally instant (ScreenTransitions.none):
both the host compose page and this screen render the same source
image at the same physical rect, so the canvas stays visually
static across the boundary while only the chrome swaps. Mirrors
telegram's animateOutToTool / animateInFromTool model.
- Mixed-in types
- Available extensions
Constructors
-
DrawScreen.borrowed({required DrawImageLayer layer, required ValueListenable<
Matrix4> camera, required ValueChanged<Rect> setFitRect, CropImageLayer? crop, EntityLayer? entities}) -
Creates the screen over the host's
layerandcamera.
Properties
-
camera
→ ValueListenable<
Matrix4> -
Host-owned viewport camera. Shared with the underlying compose
page so the editor surface stays at the same on-screen rect when
the tool pushes / pops.
final
- canPop → bool
-
Whether back pops this page: system back, the swipe and Esc. The back
gestures and the system-back state take it as the router renders, so a
page whose
canPopchanges calls XRouter.pagesChanged.no setterinherited - canSwipeBack → bool
-
Whether the back gesture (the iOS edge swipe, Android's predictive back)
drags this page, read as each one starts and as an edge swipe moves and
lifts: an edge swipe it turns off springs back. Set to
falsefor bottom sheets and overlays that dismiss differently; Android's back gesture then goes back as system back does.no setterinherited -
chromeHeight
→ ValueListenable<
double> -
Measured height of the bottom control strip. The editor's overlays
subtract it from the band they lay out in.
no setter
- claimsBack → bool
-
Whether handleBack takes back now, as a home's does while it closes a
search. While back goes to a screen that claims it, XRouter.canPop
holds, so the framework, not the OS, takes back though nothing pops. The
system-back state reads it as the router renders and after the screen
emits, so a screen whose claim changes emits, where it is a
Listenable, or calls XRouter.pagesChanged.
no setterinherited
- crop → CropImageLayer?
-
Optional crop layer from the host. When the entry has applied
crop edits, the draw editor's canvas is the cropped preview
(source × strokes → crop transform → clipped to crop rect) and
new pointer events are converted from viewport-pixels to
source-space through the crop's inverse transform — so strokes
land at the right source pixel even though the user is drawing
on the cropped view.
final
- detach ↔ VoidCallback?
-
Set by the router when pushing. Called during pop to remove the page
from the router stack and notify the delegate.
getter/setter pairinherited
- disposed → bool
-
Whether dispose has already run.
no setterinherited
- editor → Editor
-
The draw editor this screen shows.
latefinal
- entities → EntityLayer?
-
Optional entity layer from the host. Its overlays paint above the
strokes in source-space, so they clip and transform with the image
exactly as the export pipeline renders them.
final
-
future
→ Future<
bool?> -
A future that completes with the result when the page is popped.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether there is at least one active listener.
no setterinherited
- host → ScreenHost?
-
The host that pushes from inside this screen's body should
target. Defaults to parentHost — regular screens push
siblings onto their own host.
SheetScreenoverrides this to route into its own nested stack so pages pushed from inside a sheet body land within the sheet rather than escaping it.no setterinherited - isModal → bool
-
Whether this screen is a modal (dialog, bottom sheet, etc.), which Esc
pops while it is the top screen.
no setterinherited
- key → Key?
-
Identity tag used by ScreenStack to reconcile a
homeslot: same runtimeType + same key → same surface, slot State preserved. Has no effect on stack entries (diffed by==).no setterinherited - layer → DrawImageLayer
-
The draw layer being edited.
final
- parentHost ↔ ScreenHost?
-
The host that pushed this screen — set by the host on push.
Mirrors UIKit's
UIViewController.navigationController.nulluntil pushed.getter/setter pairinherited - popped ↔ bool
-
Whether this page has been popped (explicitly removed).
getter/setter pairinherited
- removed ↔ VoidCallback?
-
Set by the router when pushing. Called from onRemoved after the exit
animation completes for final cleanup (disposal).
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
setFitRect
→ ValueChanged<
Rect> -
Push the rect (in scaffold-body coords) where the image should
fit. The host's
cameraAnimatorinterpolates from compose's rect → this screen's rect on activation.final -
supportedOrientations
→ Iterable<
DeviceOrientation> -
Device orientations this screen supports while it is the topmost
visible page. The router applies the topmost screen's value via
SystemChrome.setPreferredOrientations on each active-screen
change, mirroring UIKit's per-
UIViewController.supportedInterfaceOrientations. Override to force portrait/landscape on a specific page (e.g. a camera).no setterinherited - transitionDuration → Duration
-
Duration of the enter/exit animation.
no setteroverride
-
viewerCamera
→ ValueNotifier<
Matrix4> -
Screen-local pan + zoom transform driven by two-finger gestures.
Resets to identity each DrawScreen push — the zoom is a viewport
adjustment for stroke precision, not a committed adjustment, so
it doesn't survive back on the host or into the crop editor.
latefinal
Methods
-
addDispose(
VoidCallback callback) → void -
Registers a disposal
callback. Ignored if already disposed.inherited -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object notifies its listeners.
inherited
-
buildPresenter(
BuildContext context) → Widget -
Build the page content.
override
-
buildTransition(
BuildContext context, Animation< double> animation, Widget child) → Widget -
Wrap
child(the output of buildPresenter) in a transition driven byanimation(0→1 on push, 1→0 on pop).override -
dispose(
) → void -
Releases whatever this object holds. Calling it twice is an error.
override
-
disposeBy(
Dispose disposer) → void -
Available on Disposable, provided by the DisposableDisposerExtension extension
Adds this object's dispose to another Dispose collector. -
handleBack(
) → bool -
Custom back handling, asked by system back and by a predictive back as
it commits. Return
trueto consume the back: the page stays, and a predictive back springs it back. On Android 13 and later the OS takes back that would pop nothing, unless claimsBack holds.inherited -
insertTextEntity(
) → void - Insert a text entity at the centre of the visible canvas — the fit rect less the chrome lift — and open the keyboard editor on it. Pose cancels the viewer zoom and the crop transform so the string sits upright in the current viewport.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Notifies all registered listeners.
inherited
-
onActive(
) → void -
Called when this screen becomes the topmost visible screen in the
router. Fires once after push, and again whenever it becomes topmost
after a screen above it pops or hides, or its shell shows it. Always
paired with a later onInactive.
override
-
onDetach(
) → void -
Called during pop before the future is completed.
Override for cleanup that must happen before the exit animation.
override
-
onInactive(
) → void -
Called when another screen is pushed on top, when its shell hides it,
or right before this one is popped. Mirror of onActive.
override
-
onPush(
) → void -
Called after the page is pushed onto the router.
override
-
onRemoved(
) → void -
Called after the exit animation completes and the page is fully removed.
Override for cleanup that should happen after the page is off screen.
inherited
-
pop(
[bool? result]) → void -
Remove this page. Marks as popped, detaches from the router,
and completes the future with
result.inherited -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
inherited
-
subscribe(
VoidCallback callback) → VoidCallback -
Available on Listenable, provided by the ListenableExtension extension
Addscallbackas listener and returns a function to remove it. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited