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. FakeXGalleryBackend from package: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 filter to 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 by createdAt DESC. start inclusive, end exclusive.
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.File for the asset. Photo / video alike. On Android, this stream-copies a content:// source into the app cache (since dart:io can't read content URIs directly).
saveToLibrary(String path, {required XAssetKind kind, String? mimeType}) → Future<XGallerySaveStatus>
Add the file at path to 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).