FakeXGalleryBackend class
In-memory backend for XGallery tests. Swap in via
XGallery.backend = FakeXGalleryBackend(...) before any UI
mounts; restore with XGallery.backend = ... (or by replacing
with another fake) in tearDown.
- Implemented types
Constructors
-
FakeXGalleryBackend({XGalleryPermission permissionState = XGalleryPermission.granted, List<
XAlbum> albums = const [], Map<String, List< assetsByAlbum = const {}, List<XAsset> >XAsset> recents = const [], XGalleryPermission onRequestPermission()?, void onOpenSettings()?, void onPresentLimitedLibraryPicker()?, XGallerySaveStatus onSaveToLibrary(String path, XAssetKind kind)?, XAssetThumbnail thumbnailFor(String assetId, int sizePx)?, File fileFor(String assetId)?}) - Binds the library this backend serves and the hooks tests observe.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
libraryChanges
→ Stream<
void> -
Emits whenever the underlying photo library reports a change —
limited-subset edits via
presentLimitedLibraryPicker, external edits from Photos.app, or permission flips from Settings. Subscribers should re-fetch any cached album / asset listings on each event.no setteroverride - onOpenSettings → void Function()?
-
Optional hook fired on
openSettings.final - onPresentLimitedLibraryPicker → void Function()?
-
Optional hook fired on
presentLimitedLibraryPicker.final - onRequestPermission → XGalleryPermission Function()?
-
Optional hook fired on
requestPermission. Default updatespermissionStateto XGalleryPermission.granted.final - onSaveToLibrary → XGallerySaveStatus Function(String path, XAssetKind kind)?
-
Optional hook deciding saveToLibrary's outcome; defaults to
XGallerySaveStatus.saved.
final
- permissionState ↔ XGalleryPermission
-
Mutable so tests can simulate user grant after
requestPermission.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
savedToLibrary
→ List<
String> -
Paths handed to saveToLibrary, in call order.
final
Methods
-
albums(
{XAssetKind? filter}) → Future< List< XAlbum> > -
The user's albums, optionally restricted to one asset kind.
override
-
assets(
{String? albumId, XAssetKind? filter, required int start, required int end}) → Future< List< XAsset> > -
A page of assets, newest first.
startinclusive,endexclusive.override -
emitLibraryChange(
) → void -
Tests call this to simulate the platform
photoLibraryDidChangeevent — drives any reactive reload wiring without going through the real method channel. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openSettings(
) → Future< void> -
Deep-link into the system settings page for this app.
override
-
permission(
) → Future< XGalleryPermission> -
The library's current authorisation state, without prompting.
override
-
presentLimitedLibraryPicker(
) → Future< void> -
Open the system sheet for adjusting a limited selection.
override
-
requestPermission(
) → Future< XGalleryPermission> -
Prompt for library access and report the resulting state.
override
-
resolveFile(
String assetId) → Future< File> -
A readable file for the asset, copying it out of the library where
the platform requires it.
override
-
saveToLibrary(
String path, {required XAssetKind kind, String? mimeType}) → Future< XGallerySaveStatus> -
Add the file at
pathto the library askind.override -
thumbnail(
String assetId, {required int sizePx}) → Future< XAssetThumbnail> -
A thumbnail of the asset, no larger than
sizePxon its long edge.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited