zoomable_widget
A Flutter package providing a widget for interactive viewing of widgets with pan, zoom, and rotation gestures. Designed to enhance the Flutter InteractiveViewer widget with additional features like constrained zooming with mouse scroll when holding down the left mouse button, this package is perfect for applications requiring interactive elements, such as image galleries, maps, and document viewers.
Features
- Pan, zoom, and rotate interactions with custom constraints.
- Enhanced mouse interaction: Zoom with mouse scroll when holding the left mouse button.
- Easy integration with existing Flutter projects.
- Customizable boundary margins, minimum and maximum scale values.
- Supports both predefined child widgets and builder methods for dynamic content.
Getting Started
To use the Custom Interactive Viewer in your Flutter app, add the package to your project's pubspec.yaml file:
dependencies:
zoomable_widget: ^0.0.5
Then, import the package in your Dart file:
import 'package:custom_interactive_viewer/custom_interactive_viewer.dart';
Usage
Zoomable(
maxScale: 2.5,
minScale: 0.8,
panAxis: PanAxis.free,
clipBehavior: Clip.hardEdge,
child: Image.asset('assets/my_image.png'),
)
For dynamic content based on the viewport, use the builder constructor:
Zoomable.builder(
builder: (BuildContext context, Quad viewport) {
// Return your widget based on the viewport.
// This is ideal for large or infinite content like maps.
return MyCustomWidget(viewport: viewport);
},
)