PocketBaseImageProvider class
An ImageProvider that fetches and caches images from a PocketBase instance.
Bytes are loaded through $FileService.getFileBytes, which handles the offline blob cache and RequestPolicy. Providers with the same client, record, file, thumb, scale and decode size are equal, so Flutter's ImageCache reuses the decoded image across rebuilds.
To limit memory, request a server-side thumbnail with thumb and/or a decode size with pixelWidth/pixelHeight or size.
- Inheritance
-
- Object
- ImageProvider<
PocketBaseImageProvider> - PocketBaseImageProvider
Constructors
- PocketBaseImageProvider({required $PocketBase client, required String recordId, required String recordCollectionName, required String filename, String? thumb, int? pixelWidth, int? pixelHeight, Size? size, double? scale, Duration? expireAfter, String? token, bool autoGenerateToken = false, RequestPolicy requestPolicy = RequestPolicy.cacheAndNetwork, Duration timeout = const Duration(seconds: 30)})
-
Creates an ImageProvider for a PocketBase file.
const
Properties
- autoGenerateToken → bool
-
final
- client → $PocketBase
-
final
- expireAfter → Duration?
-
How long a downloaded file stays valid in the blob cache.
final
- filename → String
-
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- pixelHeight → int?
-
Height in physical pixels to decode the image to. See pixelWidth.
final
- pixelWidth → int?
-
Width in physical pixels to decode the image to.
final
- recordCollectionName → String
-
final
- recordId → String
-
final
- requestPolicy → RequestPolicy
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double?
-
Image pixels per logical pixel; defaults to the device pixel ratio.
final
- size → Size?
-
Logical size to decode the image for, used when neither pixelWidth nor
pixelHeight is set; converted to physical pixels with the device pixel
ratio. Without any of them the image is decoded at full resolution.
final
- thumb → String?
-
PocketBase thumb spec (e.g.
'100x100','0x300') so the server sends a resized image. Thumbs are cached separately from the original file.final - timeout → Duration
-
Maximum time for the download before it counts as a network failure.
final
- token → String?
-
final
Methods
-
createStream(
ImageConfiguration configuration) → ImageStream -
Called by resolve to create the ImageStream it returns.
inherited
-
download(
) → Future< Uint8List> - Downloads the image file bytes through $FileService.getFileBytes, which applies requestPolicy and the offline blob cache.
-
evict(
{ImageCache? cache, ImageConfiguration configuration = ImageConfiguration.empty}) → Future< bool> -
Evicts an entry from the image cache.
inherited
-
loadBuffer(
PocketBaseImageProvider key, DecoderBufferCallback decode) → ImageStreamCompleter -
Converts a key into an ImageStreamCompleter, and begins fetching the
image.
inherited
-
loadImage(
PocketBaseImageProvider key, ImageDecoderCallback decode) → ImageStreamCompleter -
Converts a key into an ImageStreamCompleter, and begins fetching the
image.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
obtainCacheStatus(
{required ImageConfiguration configuration, ImageErrorListener? handleError}) → Future< ImageCacheStatus?> -
Returns the cache location for the key that this ImageProvider creates.
inherited
-
obtainKey(
ImageConfiguration configuration) → Future< PocketBaseImageProvider> -
Converts an ImageProvider's settings plus an ImageConfiguration to a key
that describes the precise image to load.
override
-
resolve(
ImageConfiguration configuration) → ImageStream -
Resolves this image provider using the given
configuration, returning an ImageStream.inherited -
resolveStreamForKey(
ImageConfiguration configuration, ImageStream stream, PocketBaseImageProvider key, ImageErrorListener handleError) → void -
Called by resolve with the key returned by obtainKey.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override