MediaPickerPage class

A media-library sheet with a live camera cell and maxSelection picks.

The sheet and grid coordinate scrolling through SheetController. Gallery edits remain picker-owned across editor cancellation. Captures are composed independently of gallery selections; confirmation dismisses the picker.

Mixed-in types
Available extensions

Constructors

MediaPickerPage({int maxSelection = 10, XAssetKind? filter, ComposeSubmitCallback? onSubmit, ComposePurpose composePurpose = ComposePurpose.mediaMessage, int? maxImageExtent})
Creates the picker.

Properties

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 canPop changes 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 false for 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
composePurpose → ComposePurpose
Which compose surface to show after picking. Avatar flows reuse the image tools but suppress chat-only caption UI.
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
displayMode → DisplayMode
Whether the grid or the strip of picked assets shows.
no setter
disposed → bool
Whether dispose has already run.
no setterinherited
filter → XAssetKind?
Restricts the library and camera output; null permits photos and videos.
final
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?
Pushes from inside this sheet body target the nested stack, not the parent host that pushed the sheet. Use parentHost (inherited from Screen) to escape the modal — rare.
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 home slot: 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
maxSelection → int
How many assets may be picked.
final
nestedHost → ScreenHost
Public-typed view of the sheet's nested host.
no setterinherited
onSubmit → ComposeSubmitCallback?
Called by the editor before confirmation to provide send-transition targets.
final
parentHost ↔ ScreenHost?
The host that pushed this screen — set by the host on push. Mirrors UIKit's UIViewController.navigationController. null until 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
selection → SelectionContext
The picked assets.
latefinal
sheetBackgroundColor → Color
Sheet background. Override for theme-driven colors.
no setteroverride
sheetBarrierColor → Color
Backdrop scrim color. Sheet fades alpha from 0 (offscreen) to barrierColor.a (fully collapsed).
no setteroverride
sheetBorderRadius → double
Top-corner radius. Bottom corners shrink toward 0 as the sheet expands.
no setterinherited
sheetCollapsedExtent → double
Initial height as a fraction of the viewport (0.0–1.0). Defaults to 0.55 — telegram's standard half-sheet.
no setterinherited
sheetController → SheetController
Scroll-coordination controller. Inner scroll views attach via SheetController.attach(scrollController) and use controller.physics so the sheet drag and the list scroll hand off cleanly at scroll-top.
latefinalinherited
sheetIsDismissible → bool
Whether the backdrop tap and drag-down past threshold dismiss the sheet. When false, only programmatic pop closes it.
no setterinherited
sheetIsFullSize → bool
When true, the sheet enters at full screen and never collapses. Drag-to-dismiss is gated to a higher distance threshold.
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
Zero-duration route transition — the Sheet widget self-manages its slide-up entry via its own internal animation controller.
no setterinherited

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.
inherited
buildSheetBody(BuildContext context) → Widget
Override to provide the sheet's content. Renders below the drag-handle pill (SheetThumb) as the home of the sheet's nested navigation stack.
override
buildTransition(BuildContext context, Animation<double> animation, Widget child) → Widget
Wrap child (the output of buildPresenter) in a transition driven by animation (0→1 on push, 1→0 on pop).
inherited
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.
handleAllowAccess() → Future<void>
Requests photo access and reloads the authorized library.
handleAssetTap(XAsset asset) → Future<void>
Tap router for grid cells. Cell-body taps always open compose at that single asset — selection is reserved for the ring tap (top-right of each cell). Matches telegram parity: tapping a thumbnail opens the viewer; the ring is the only path to add / remove a multi-pick.
handleBack() → bool
Back goes to the top nested page first: its handleBack, then, unless that consumes the back, a pop where its canPop holds. With the nested stack empty, declines — the router's pop-the-top fallback then dismisses the sheet itself.
inherited
handleCameraAccess() → Future<void>
Requests camera access, opening Settings when a prompt is unavailable.
handleCameraTap() → Future<void>
Captures with the grid's session and composes independently of selection.
handleCancel() → Future<void>
Dismisses the sheet and pops without a result.
handleManageLimited() → Future<void>
Opens the system sheet that changes which photos the app may read.
handleSend() → Future<void>
Push ComposePage.borrowed with the picker-owned entries for the current selection. Pops the picker on Send (with compose's per-entry results); stays open on Cancel so edits are still visible in the grid.
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.
inherited
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.
inherited
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
openAlbums() → Future<void>
Push the album browser onto the sheet's nested stack (host?.push(AlbumsScreen)); on pop with a non-null result, switch the active album. Mirrors telegram's MediaPickerScreen → MediaGroupsScreen → pop-with-collection flow.
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
selectAlbum(XAlbum? album) → Future<void>
Switch to album (or null for Recents) and reload the grid.
setDisplayMode(DisplayMode mode) → void
Shows mode; the strip only while something is picked.
subscribe(VoidCallback callback) → VoidCallback

Available on Listenable, provided by the ListenableExtension extension

Adds callback as listener and returns a function to remove it.
toggleDisplayMode() → void
Switches between the grid and the strip.
toString() → String
A string representation of this object.
inherited
transitionSourceFor(Object assetId) → GallerySource?
Central transition-source lookup. Compose's hero-flight calls this at dismiss time to find the cell to land on — the picker picks the right view based on its own current state, so the animation always targets what the user can see. Mirrors telegram-iOS's MediaPickerScreen.transitionView(for:). Reads the mounted thumbnail registry; returns null when the matching cell is off-screen, picker-unmounted, or not in the active album.

Operators

operator ==(Object other) → bool
The equality operator.
inherited