zoom_viewer 1.0.3
zoom_viewer: ^1.0.3 copied to clipboard
A Flutter package that makes any widget zoomable with pinch and pan gestures, just like zooming images in a gallery. Perfect for image viewers, charts, and interactive content.
ZoomViewer #
A powerful and easy-to-use Flutter package that makes any widget zoomable with pinch and pan gestures, just like zooming images in a gallery. Perfect for image viewers, charts, diagrams, and any interactive content that needs zoom functionality.
โจ Features #
- ๐ Universal Zoom - Works with ANY Flutter widget (Images, Containers, Custom Widgets, Charts, etc.)
- ๐ Pinch Gesture - Intuitive pinch to zoom in/out
- ๐๏ธ Pan Support - Smoothly pan around when zoomed
- ๐ Double Tap - Quick zoom toggle with double tap
- โ๏ธ Highly Customizable - Configure min/max scale, animations, and more
- ๐จ Smooth Animations - Beautiful, configurable animations
- ๐ Real-time Callbacks - Get notified when zoom level changes
- ๐ฏ Production Ready - Well-tested and documented
- ๐ฑ Cross Platform - Works on iOS, Android, Web, Windows, macOS, and Linux
๐ฆ Installation #
Add this to your package's pubspec.yaml file:
dependencies:
zoom_viewer: ^1.0.3
or
flutter pub add zoom_viewer
Then run:
flutter pub get
๐ Quick Start #
Import the package:
import 'package:zoomable_widget/zoomable_widget.dart';
Wrap any widget with ZoomViewer:
ZoomViewer(
child: Image.network('https://example.com/image.jpg'),
)
That's it! Your widget is now zoomable. ๐
๐ Usage Examples #
Basic Image Viewer #
ZoomViewer(
minScale: 0.5,
maxScale: 4.0,
child: Image.asset('assets/photo.jpg'),
)
Custom Container #
ZoomViewer(
minScale: 0.5,
maxScale: 4.0,
backgroundColor: Colors.black,
child: Container(
width: 300,
height: 300,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
'Zoom Me!',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
),
),
)
With Zoom Callback #
ZoomViewer(
minScale: 0.5,
maxScale: 5.0,
onScaleChanged: (scale) {
print('Current zoom level: ${scale.toStringAsFixed(2)}x');
},
child: YourCustomWidget(),
)
Complex Widget Example #
ZoomViewer(
minScale: 0.3,
maxScale: 3.0,
initialScale: 1.0,
enablePan: true,
resetOnDoubleTap: true,
backgroundColor: Colors.grey[200],
animationDuration: Duration(milliseconds: 300),
clipBehavior: true,
onScaleChanged: (scale) {
setState(() {
currentZoom = scale;
});
},
child: YourComplexWidget(),
)
Image Gallery Viewer #
PageView.builder(
itemCount: images.length,
itemBuilder: (context, index) {
return ZoomViewer(
minScale: 0.5,
maxScale: 4.0,
child: Image.network(images[index]),
);
},
)
๐๏ธ Configuration Parameters #
| Parameter | Type | Default | Description |
|---|---|---|---|
child |
Widget |
required | The widget to make zoomable |
minScale |
double |
0.5 |
Minimum zoom scale (must be > 0 and โค 1.0) |
maxScale |
double |
4.0 |
Maximum zoom scale (must be โฅ 1.0) |
initialScale |
double |
1.0 |
Initial zoom scale (between min and max) |
enablePan |
bool |
true |
Enable/disable panning gesture |
backgroundColor |
Color? |
null |
Background color behind the widget |
onScaleChanged |
ValueChanged<double>? |
null |
Callback fired when zoom level changes |
resetOnDoubleTap |
bool |
true |
Reset zoom on double tap |
animationDuration |
Duration |
300ms |
Duration for zoom animations |
clipBehavior |
bool |
true |
Whether to clip the child widget |
๐ฎ Gestures #
- Pinch: Zoom in/out with two fingers
- Pan: Move around when zoomed in (single finger drag)
- Double Tap: Toggle between zoomed and initial state
๐ก Real-World Use Cases #
- ๐ธ Photo Galleries - Create Instagram-like image viewers
- ๐ Charts & Graphs - Allow users to zoom into data visualizations
- ๐บ๏ธ Maps & Diagrams - Interactive map exploration
- ๐ Document Viewers - PDF-like zoom functionality
- ๐จ Design Tools - Zoom into design mockups or blueprints
- ๐ Educational Apps - Zoom into detailed diagrams and illustrations
- ๐๏ธ Floor Plans - Interactive building plan viewers
- ๐งฉ Puzzle Games - Zoom interface for detailed game boards
๐ Running the Example #
The package includes a complete example app with three different demos:
cd example
flutter pub get
flutter run
The example includes:
- Simple Container - Basic zoomable colored box
- Gradient Box - Beautiful gradient design with zoom
- Complex Widget - Full user profile card with zoom
๐ฑ Platform Support #
| Platform | Supported |
|---|---|
| Android | โ |
| iOS | โ |
| Web | โ |
| Windows | โ |
| macOS | โ |
| Linux | โ |
๐งช Testing #
The package includes comprehensive unit tests. Run them with:
flutter test
๐ค Contributing #
Contributions are welcome! Here's how you can help:
- ๐ Report bugs and issues
- ๐ก Suggest new features
- ๐ Improve documentation
- ๐ง Submit pull requests
Please read CONTRIBUTING.md for details on our code of conduct and development process.
๐ Changelog #
See CHANGELOG.md for a detailed list of changes in each version.
๐ Issues #
If you encounter any issues, please file them on our issue tracker.
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐จโ๐ป Author #
Abubakar (AbubakrFlutter)
- GitHub: @AbubakrFlutter
โญ Show Your Support #
If you like this package, please give it a โญ on GitHub and a ๐ on pub.flutter-io.cn!
๐ Acknowledgments #
Thanks to the Flutter team for creating such an amazing framework and to all contributors who help make this package better!
Made with โค๏ธ for the Flutter community