XGallery class
Static facade for the system photo library. All state lives in the platform; this class is a thin Dart-side wrapper that dispatches into backend.
On Android it asks for and lists only the media kinds the app's merged
manifest declares: photos with READ_MEDIA_IMAGES, which
ux: enable_gallery_photos: true merges, and videos with
READ_MEDIA_VIDEO, which ux: enable_gallery_videos: true merges.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- backend ↔ XGalleryBackend
-
Swap to inject a fake (e.g.
FakeXGalleryBackendfrompackage:ux/testing.dart) before any UI code mounts.getter/setter pair -
libraryChanges
→ Stream<
void> -
Emits whenever the system photo library changes — limited-subset
edits, external edits, permission changes. Picker UIs subscribe
to reload their cached asset list reactively.
no setter
- supportsSaveToLibrary → bool
-
Whether saveToLibrary has a native implementation on this
platform. iOS / Android only — desktop builds keep downloaded media
in user-visible folders rather than a photo library.
no setter
Static Methods
-
albums(
{XAssetKind? filter}) → Future< List< XAlbum> > -
Albums in the user's library, ordered Recents → smart → user.
Pass
filterto restrict to image-only / video-only albums. -
assets(
{String? albumId, XAssetKind? filter, required int start, required int end}) → Future< List< XAsset> > -
Paginate assets within
albumId(or all assets if null), sorted bycreatedAt DESC.startinclusive,endexclusive. -
openSettings(
) → Future< void> - Deep-links into the system settings page for this app — the only route back from XGalleryPermission.denied.
-
permission(
) → Future< XGalleryPermission> - The library's current authorisation state, without prompting.
-
presentLimitedLibraryPicker(
) → Future< void> - iOS 14+ only — opens the system "manage limited access" sheet. No-op on Android / older iOS.
-
requestPermission(
) → Future< XGalleryPermission> - Prompts for library access and reports the resulting state.
-
resolveFile(
String assetId) → Future< File> -
Resolve a real
io.Filefor the asset. Photo / video alike. On Android, this stream-copies acontent://source into the app cache (sincedart:iocan't read content URIs directly). -
saveToLibrary(
String path, {required XAssetKind kind, String? mimeType}) → Future< XGallerySaveStatus> -
Add the file at
pathto the system photo library. -
thumbnail(
String assetId, {required int sizePx}) → Future< XAssetThumbnail> -
Cell-sized thumbnail at
~max(width,height) <= sizePx. Native caches keep repeated calls cheap; the caller still maintains a small Dart-side LRU keyed by(assetId, sizePx).