flutter photo view
a simple zoomable image widget for flutter
photo view is useful in full-screen exhibition cases.
resolves an image provider and show the result with useful gestures support, such as pinch to zoom and pan.
installation
add photo_view
as a dependency in your pubspec.yaml file.
import photo view:
import 'package:photo_view/photo_view.dart';
sample code
given a imageprovider imageprovider
(such as assetimage or networkimage):
@override
widget build(buildcontext context) {
return new container(
child: new photoview(
imageprovider: assetimage("assets/large-image.jpg"),
minscale: photoviewcomputedscale.contained * 0.8,
maxscale: 4.0,
);
);
}
inline usage
if you want photoview
to scale the image in container with size different than the screen, use photoviewinline
instead.
@override
widget build(buildcontext context) {
return new container(
child: new photoviewinline(
imageprovider: assetimage("assets/large-image.jpg"),
minscale: photoviewcomputedscale.contained * 0.8,
maxscale: 4.0,
);
);
}
api
for more information about how to use photo view, check the api docs
screenshots
limited scale | inline | hero animation |
---|---|---|
todo:
- [x] scale on doubletap
- [x] zoom when pinched
- [x] respect screen and image boundaries
- [x] center image when zooming out
- [x] add image zoom limits (
minscale
anmaxscale
) - [x] add gif support
- [ ] multiple image support (gallery mode)
- [ ] rotate gesture rotates image (work in progress)
pull requests are welcome.
Comments are closed.