diff --git a/lib/gallery_item_thumbnail.dart b/lib/gallery_item_thumbnail.dart index 4013367..95aee47 100644 --- a/lib/gallery_item_thumbnail.dart +++ b/lib/gallery_item_thumbnail.dart @@ -6,6 +6,7 @@ import 'gallery_item_model.dart'; // to show image in Row class GalleryItemThumbnail extends StatelessWidget { final GalleryItemModel galleryItem; + final GestureTapCallback? onLongPress; final GestureTapCallback? onTap; final Widget? loadingWidget; final Widget? errorWidget; @@ -14,6 +15,7 @@ class GalleryItemThumbnail extends StatelessWidget { const GalleryItemThumbnail( {Key? key, required this.galleryItem, + required this.onLongPress, required this.onTap, required this.radius, required this.loadingWidget, @@ -23,6 +25,7 @@ class GalleryItemThumbnail extends StatelessWidget { @override Widget build(BuildContext context) { return GestureDetector( + onLongPress: onLongPress, onTap: onTap, child: Hero( tag: galleryItem.id, diff --git a/lib/galleryimage.dart b/lib/galleryimage.dart index 7c8c3c2..35a7fe9 100644 --- a/lib/galleryimage.dart +++ b/lib/galleryimage.dart @@ -29,7 +29,8 @@ class GalleryImage extends StatefulWidget { final bool showAppBar; final bool closeWhenSwipeUp; final bool closeWhenSwipeDown; - + final void Function(int)? onImagePress; + const GalleryImage({ Key? key, required this.imageUrls, @@ -53,6 +54,7 @@ class GalleryImage extends StatefulWidget { this.showAppBar = true, this.closeWhenSwipeUp = false, this.closeWhenSwipeDown = false, + this.onImagePress, }) : assert(numOfShowImages <= imageUrls.length), super(key: key); @override @@ -89,6 +91,9 @@ class _GalleryImageState extends State { ? _buildImageNumbers(index) : GalleryItemThumbnail( galleryItem: galleryItems[index], + onLongPress: () { + widget.onImagePress?.call(index); + }, onTap: () { _openImageFullScreen(index); }, @@ -102,6 +107,9 @@ class _GalleryImageState extends State { // build image with number for other images Widget _buildImageNumbers(int index) { return GestureDetector( + onLongPress: () { + widget.onImagePress?.call(index); + }, onTap: () { _openImageFullScreen(index); }, @@ -114,6 +122,7 @@ class _GalleryImageState extends State { loadingWidget: widget.loadingWidget, errorWidget: widget.errorWidget, onTap: null, + onLongPress: null, radius: widget.imageRadius, ), ClipRRect( diff --git a/pubspec.yaml b/pubspec.yaml index 8140153..6cb090a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: galleryimage description: Flutter plugin that list of images from URLs allows you to display and zoomable multi image on iOS and Android. -version: 2.0.1 +version: 2.0.2 homepage: https://github.com/BeshoyMelika/flutter-gallery-package environment: