SwipeImageGallery constructor
SwipeImageGallery({
- required BuildContext context,
- List<
Widget> ? children, - IndexedWidgetBuilder? itemBuilder,
- int? itemCount,
- bool hideStatusBar = true,
- int initialIndex = 0,
- Color backgroundColor = Colors.black,
- int dismissDragDistance = 160,
- int transitionDuration = 400,
- bool hideOverlayOnTap = true,
- double zoom = 8.0,
- double backgroundOpacity = 1.0,
- ImageGalleryController? controller,
- void onSwipe()?,
- StreamController<
Widget> ? overlayController, - Widget? initialOverlay,
- 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,
});