LocalImageProvider class

An interface to get information from the local image storage on the device.

Use LocalImageProvider to query for albums and images. The general flow is as follows:

  LocalImageProvider lip = LocalImageProvider();
  await lip.initialize();
  if ( lip.isAvailable ) {
    List<LocalImage> images = await lip.findLatest(10);
    if ( images.isNotEmpty) {
      // Do stuff with the image
    }
  }
  else {
    print('Access denied.');
  }

Constructors

LocalImageProvider()
Returns the singleton instance of the LocalImageProvider.
factory
LocalImageProvider.testInstance()
This is useful for testing because it carries no state
factory

Properties

cacheAll → bool
Returns true if all DeviceImage should be cached in the global Flutter imageCache.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasLimitedPermission → Future<bool>
Returns true only for iOS 14+ if the user chose to grant only limited access to the photos in their library.
no setter
hasPermission → Future<bool>
Returns true if the user has already granted permission to access photos.
no setter
imgBytesLoaded → int
Returns the total bytes loaded in imageBytes since the last call to resetStats.
no setter
isAvailable → bool
True if initialize succeeded and the user granted permission to access local images.
no setter
lastLoadTime → int
Returns the milliseconds spent in the last call to imageBytes assuming that resetStats wasn't called after the last call.
no setter
maxCacheDimension ↔ int
The maximum size at which a DeviceImage should be cached in the global Flutter imageCache.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
totalLoadTime → int
Returns the total milliseconds spent in imageBytes since the last call to resetStats.
no setter

Methods

cleanup() → Future
Call this method to cleanup any temporary files that have been created by the image provider.
findAlbums(LocalAlbumType localAlbumType) → Future<List<LocalAlbum>>
Returns the list of LocalAlbum available on the device matching the localAlbumType
findImagesInAlbum(String albumId, int maxImages) → Future<List<LocalImage>>
Returns the images contained in the given album on the local device up to maxImages in length.
findLatest(int maxImages) → Future<List<LocalImage>>
Returns the newest images on the local device up to maxImages in length.
imageBytes(String id, int height, int width, {int? compression}) → Future<Uint8List>
Returns a version of the image at the given size in a jpeg format suitable for loading with MemoryImage.
initialize() → Future<bool>
Initialize and request permission to use platform services.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resetStats() → void
Resets the totalLoadTime, lastLaodTime, and imgBytesLoaded stats to zero.
toString() → String
A string representation of this object.
inherited
videoFile(String id) → Future<String>
Returns a temporary file path for the requested video.

Operators

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

Constants

cacheAtAnySize → const int
cacheSuggestedCutoff → const int