CropScreen class
Pushed tool screen for the crop editor. Borrows a CropImageLayer
from the host (e.g. ComposeEntry); on push the layer snapshots its
state, on cancel it restores from the snapshot, on apply it commits
(current state IS committed). Pops with true on apply / false on
cancel. The host re-renders its preview from the committed layer
state: an image's preview is the composite ComposeEntry.composedImage
gives the submit, and a video's crop rides ComposeResult.videoEdit.
See DrawScreen for the rationale behind the instant
ScreenTransitions.none transition and shared-image model.
- Mixed-in types
- Available extensions
Constructors
-
CropScreen.borrowed({required CropImageLayer layer, required ValueListenable<
Matrix4> camera, required ValueChanged<Rect> setFitRect, void refitCamera({Curve? curve, Duration? duration})?, DrawImageLayer? draw, 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 - 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
- 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
- draw → DrawImageLayer?
-
Optional draw layer from the host. When the entry has prior
strokes, the crop editor renders them on top of the source so
the user can see what they've drawn while adjusting the crop
handles. Strokes paint at source-space coords through the same
imageTransformas the image, so they rotate/flip together.final - editor → Editor
-
The crop editor this screen shows.
latefinal
- entities → EntityLayer?
-
Optional entity layer from the host. Its overlays render on top of
the source through the same
imageTransformas the strokes, so the user sees them rotate / flip while adjusting the crop handles.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 → CropImageLayer
-
The crop 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
- refitCamera → void Function({Curve? curve, Duration? duration})?
-
Re-target the host camera at the current crop rect — telegram's
evenlyFill refit. Invoked on the layer's confirm tick (1s after
a handle drag, immediately on an aspect snap) with the TgSpring.
final
- 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, so the image animates smoothly from compose's position to crop's. On pop, compose'sonActivere-pushes its own rect and the animator runs the reverse transition.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
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 -
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