A powerful Flutter library for displaying interactive image and video galleries with smooth transitions and rich gesture support.
- 🖼️ Seamless image and video preview gallery
- 🔍 Interactive zoom with two-finger gestures
- 👆 Double-tap to zoom in/out
- 🔄 Smooth horizontal navigation between media items
- ↩️ Intuitive gesture-based dismissal with scale, translation, and background opacity effects
- ⏯️ Automatic video pausing when not in focus
- ✨ Hero animations for elegant transitions
Add this to your package's pubspec.yaml file:
dependencies:
interactive_media_gallery: ^1.0.0Then run:
flutter pub get- Wrap your grid items with
Herowidgets for smooth transitions:
Hero(
tag: source.url, // Unique identifier for the Hero animation
child: YourGridViewItem(),
)- Create a gallery view with your data model:
void openGallery(YourDataModel source) {
Navigator.of(context).push(
HeroDialogRoute<void>(
builder: (BuildContext context) => InteractiveMediaGallery<YourDataModel>(
sources: sourceList,
initIndex: sourceList.indexOf(source),
itemBuilder: (context, index, isFocused) {
// Build your gallery item based on your data model
return YourGalleryItemWidget(
source: sourceList[index],
isFocused: isFocused,
);
},
onPageChanged: (int pageIndex) {
// Handle page change events
print("Current page: $pageIndex");
},
),
),
);
}The InteractiveMediaGallery widget supports several customization options:
InteractiveMediaGallery<YourDataModel>(
sources: sourceList,
initIndex: initialIndex,
itemBuilder: itemBuilder,
maxScale: 3.0, // Maximum zoom scale (default: 2.5)
minScale: 0.8, // Minimum zoom scale (default: 1.0)
pageController: customPageController, // Optional custom page controller
onPageChanged: onPageChangedCallback,
)Check out the example project for a complete implementation.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.