SwipeImageGallery constructor

SwipeImageGallery({
  1. required BuildContext context,
  2. List<Widget>? children,
  3. IndexedWidgetBuilder? itemBuilder,
  4. int? itemCount,
  5. bool hideStatusBar = true,
  6. int initialIndex = 0,
  7. Color backgroundColor = Colors.black,
  8. int dismissDragDistance = 160,
  9. int transitionDuration = 400,
  10. bool hideOverlayOnTap = true,
  11. double zoom = 8.0,
  12. double backgroundOpacity = 1.0,
  13. ImageGalleryController? controller,
  14. void onSwipe(
    1. int
    )?,
  15. StreamController<Widget>? overlayController,
  16. Widget? initialOverlay,
  17. List<ImageGalleryHeroProperties>? heroProperties,
})

A scrollable, dismissable by swiping, zoomable, rotatable image gallery on which you can add a dynamic overlay.

SwipeImageGallery utilizes PageView and InteractiveViewer for its main functionality.

When showing a new gallery you can either use images or the itemBuilder and itemCount combination to add the images.

Here's an example using the images:

final assets = const [
  Image(image: AssetImage('assets/1.jpeg')),
  Image(image: AssetImage('assets/2.jpeg')),
  Image(image: AssetImage('assets/3.jpeg')),
  Image(image: AssetImage('assets/4.jpeg')),
];

...

ElevatedButton(
  onPressed: () => SwipeImageGallery(
    context: context,
    children: assets,
  ).show(),
  child: Text('Open Gallery With Assets'),
),

And another example with itemBuilder and itemCount.

final urls = [
  'https://via.placeholder.com/400',
  'https://via.placeholder.com/800',
  'https://via.placeholder.com/900x350',
  'https://via.placeholder.com/1000',
  'https://via.placeholder.com/100',
];

...

ElevatedButton(
  onPressed: () => SwipeImageGallery(
    context: context,
    itemBuilder: (context, index) {
      return Image.network(urls[index]);
    },
    itemCount: urls.length,
  ).show(),
  child: Text('Open Gallery With Builder'),
),

Implementation

SwipeImageGallery({
  required this.context,
  this.children,
  this.itemBuilder,
  this.itemCount,
  this.hideStatusBar = true,
  this.initialIndex = 0,
  this.backgroundColor = Colors.black,
  this.dismissDragDistance = 160,
  this.transitionDuration = 400,
  this.hideOverlayOnTap = true,
  this.zoom = 8.0,
  this.backgroundOpacity = 1.0,
  this.controller,
  this.onSwipe,
  this.overlayController,
  this.initialOverlay,
  this.heroProperties,
});