ComposePage class
Folded single + multi compose page. Accepts a list of XMedia
(1..N); single-asset callers wrap with [m]. The PageView is
non-swipeable when N == 1 and the dot indicator hides for the
same case — single-asset surface is identical to today, just
without the swipe / dots.
Telegram parity: per-entry state lives on each ComposeEntry
(composer controller, viewer transform, video controller,
persistent editor layers); chrome is shared and rebinds to the
focused entry on page change. Edits stay as vector state on the
layers; handleSubmit puts each entry's composedImage() (the
composite of its current edits, null without image edits) in its
ComposeResult, and a video's edits ride ComposeResult.videoEdit.
- Mixed-in types
- Available extensions
Constructors
-
ComposePage({required List<
XMedia> assets, ComposeSubmitCallback? onSubmit, ComposePurpose purpose = ComposePurpose.mediaMessage, int? maxImageExtent}) - Standalone: creates one fresh ComposeEntry per input media, disposes all entries on pop. Used by camera / file-pick flows that don't have a long-lived picker scope to hold per-asset edits across re-entries.
-
ComposePage.borrowed({required List<
ComposeEntry> entries, Rect? initialSourceRect, Image? initialSnapshot, BorderRadius initialSourceRadius = BorderRadius.zero, GallerySource? transitionSourceFor(Object id)?, ComposeSubmitCallback? onSubmit, ComposePurpose purpose = ComposePurpose.mediaMessage, int? maxImageExtent}) -
Borrowed: reuses entries the caller (the picker) holds and holds
each until
dispose(), so an entry lives until both have left and per-asset state (crop / draw / caption / rendered preview) survives re-entry of compose during one picker session.
Properties
-
assets
→ List<
XMedia> -
The media being composed.
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
-
composerBubbleKey
→ GlobalKey<
State< StatefulWidget> > -
Key of the caption field's bubble.
latefinal
- composerFocus → FocusNode
-
Focus of the caption field.
latefinal
-
currentIndex
→ ValueNotifier<
int> -
Index of the entry in front.
latefinal
- 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
-
dragOffset
→ ValueNotifier<
double> -
Vertical offset of a drag-to-dismiss in progress.
latefinal
-
entries
→ List<
ComposeEntry> -
One entry per asset: the borrowed ones, else created here.
latefinal
- focusedEntry → ComposeEntry
-
The entry in front.
no setter
-
future
→ Future<
List< ComposeResult> ?> -
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 - initialSnapshot → Image?
-
Picker-side bubble snapshot at push time. Disposed on screen
removal so the GPU bitmap doesn't leak.
final
- initialSourceRadius → BorderRadius
-
Opening thumbnail corners, applied by the flight.
final
- initialSourceRect → Rect?
-
Opening thumbnail bounds; absence uses an in-place media fade.
final
- 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 - maxImageExtent → int?
-
Longest edge, in pixels, of an avatar result's
ComposeResult.imageBytes; absent keeps the image's own size.
final
- onSubmit → ComposeSubmitCallback?
-
Caller-provided submit handler. Compose awaits this with the
per-entry results before popping; the returned cids are used
as the close hero destination.
final
- ownsEntries → bool
-
True when this page owns the entries (standalone mode); false
when entries are borrowed from a host (picker). Drives the
dispose()decision.final - pageController → PageController
-
Pages between entries.
latefinal
- 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
- purpose → ComposePurpose
-
What the results are for.
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
-
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
- transitionSourceFor → GallerySource? Function(Object id)?
-
Picker-provided lookup for the close hero-flight destination.
Closes over the picker's current
_displayModeso dismiss always lands on whichever view (grid or strip) is in front. Absence uses an in-place fade and shrink.final
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 -
handleCancel(
) → void - Pops without a result.
-
handleSubmit(
) → Future< void> -
Walk each entry and capture (a) the original picker media,
(b) the in-memory composited image for edited entries, then
invoke onSubmit before pop so the chat bubbles exist by
the time the close hero captures its destination. Mirrors
telegram's
completion(results, finishedCallback)order: insert first, thenanimateOut(finished: true). -
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.
inherited
-
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.
override
-
pop(
[List< ComposeResult> ? 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