Last updated:
0 purchases
pdf thumbnail
Pdf Thumbnail #
Thumbnail viewer for pdfs
Installation π» #
β In order to start using Pdf Thumbnail you must have the Flutter SDK installed on your machine.
Add pdf_thumbnail to your pubspec.yaml:
dependencies:
pdf_thumbnail:
copied to clipboard
Install it:
flutter packages get
copied to clipboard
Example βοΈ #
return Stack(
children: [
SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: PdfViewer(
filePath: snapshot.data!.path,
),
),
if (showThumbnail)
Positioned(
bottom: 0,
width: MediaQuery.of(context).size.width,
// Here's the thumbnail widget.
child: PdfThumbnail.fromFile(snapshot.data!.path),
),
],
);
copied to clipboard
There is a detailed example app in the repo, but I've deleted iOS and Android folders.
Simple go to example folder, and run flutter create . inside the folder to add missing native files for the example app.
Demo
Caching β² #
I left caching part unopinionated to keep the package simple. Just create your own class from ImageThumbnailCacher and implement the read/write methods.
Holding images as Uint8List, so Map<int, Uint8List> is what's need to be written to and read from the cache. It maps page numbers to the images.
class ThumbnailCacher implements ImageThumbnailCacher {
@override
Future<PageToImage?> read(String id) async {
return api.localStorage.readThumbnails(id);
}
@override
Future<bool> write({required String id, required PageToImage map}) {
return api.localStorage.writeThumbnails(id: id, map: map);
}
}
copied to clipboard
I'm using Hive to cache.
Roadmap πΊοΈ #
β
Customization for colors, decoration etc.
β
onTap callback and page number.
β
Caching.
β Different layouts and scroll axises.
β Lazy loading.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.