getThumbnail method

  1. @override
Future<String?> getThumbnail({
  1. required String uriOrPath,
  2. int width = 256,
  3. int? height,
  4. int dateModified = 0,
  5. String kind = 'image',
})
override

Generates (or returns a cached) thumbnail for any media file.

Returns the absolute path to the cached JPEG on disk, or null on failure. Callers should use Image.file(File(path)) to display it.

uriOrPathcontent:// URI (Android) or absolute file path. width – thumbnail width in logical pixels (default 256). height – thumbnail height in logical pixels (default = width). dateModified – epoch-ms stamp used for cache invalidation. kind"image" | "video" | "audio".

Implementation

@override
Future<String?> getThumbnail({
  required String uriOrPath,
  int width = 256,
  int? height,
  int dateModified = 0,
  String kind = 'image',
}) async {
  final result = await methodChannel.invokeMethod<String>('getThumbnail', {
    'uri': uriOrPath,
    'width': width,
    'height': height ?? width,
    'dateModified': dateModified,
    'kind': kind,
  });
  return result;
}