Package selection guidance compiled from public package information, community data, and project usage.
The image_compare_slider package enables seamless side-by-side image comparison using a draggable slider handle. It allows users to reveal one image gradually as they slide the handle, making it ideal for before-and-after visualizations. Fully customizable with options for handle appearance, slider position, and animation speed, it supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. The package is lightweight and integrates easily into Flutter apps with minimal setup.
Use cases
Before-and-after photo comparisons
Product feature demonstrations
Visual design reviews
Educational image analysis
User interface testing
Key features
Draggable slider handle
Customizable handle and track
Smooth transition animation
Cross-platform support
Easy integration with Flutter
Configurable initial position
Suitable for
App developers needing visual comparison tools
Designers showcasing image changes
Educational app creators
E-commerce product previews
Interactive UI components
Considerations
Requires two images of equal size for best results
Performance may vary with large images
Limited to horizontal sliding layout
Custom styling requires understanding of Flutter widgets
May need additional padding or constraints in complex layouts
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Image Compare Slider
Inspired by react-compare-slider, this package allows you to easily compare two images with a slider — with zoom & pan, rotation (with lock), custom handles and size matching.
PR's are welcome!
Installation 💻
❗ In order to start using Image Compare you must have the Dart SDK installed on your machine.
Drives position, zoom, pan and rotation programmatically
handleBuilder
HandleBuilder?
Builds a fully custom, draggable handle widget
onlyHandleDraggable
bool
Restrict slider movement to dragging the handle
fit
BoxFit
How both images are inscribed into their box (default BoxFit.contain)
aspectRatio
double?
Force both images into the same box to match different sizes
zoomable
bool
Enable pinch / double-tap zoom on both images
pannable
bool
Enable drag-to-pan on both images
enableGestureRotation
bool
Enable two-finger rotation gestures
doubleTapToZoom
bool
Toggle zoom on double-tap (default true)
minScale / maxScale
double
Zoom bounds (default 1.0 / 5.0)
doubleTapScale
double
Zoom factor applied on double-tap (default 2.5)
If you want to add some effects you can use the itemOneBuilder and itemTwoBuilder parameters to wrap the images with a ColorFilter or ImageFilter, or any other widget you want.
For example, to add a ImageFilter with a blur effect:
You can also pass any custom properties to the Image for itemOne and itemTwo, and most of the Image properties will be applied to the ImageCompareSlider widget.
For example, adding a colorBlendMode with a color to itemOne:
Control how the divider line is stroked with dividerLineStyle. Pick a preset
or build a fully custom dash pattern. This only affects the painted line, not
the handle.
// Solid (the default).ImageCompareSlider(
itemOne: constImage.asset('...'),
itemTwo: constImage.asset('...'),
dividerLineStyle: constDividerLineStyle.solid(),
);
// Dashed — dashes of `dashLength` separated by `gapLength` (logical pixels).ImageCompareSlider(
itemOne: constImage.asset('...'),
itemTwo: constImage.asset('...'),
dividerLineStyle: DividerLineStyle.dashed(dashLength: 10, gapLength: 6),
);
// Dotted — round dots whose diameter equals `dividerWidth`.ImageCompareSlider(
itemOne: constImage.asset('...'),
itemTwo: constImage.asset('...'),
dividerWidth: 4,
dividerLineStyle: DividerLineStyle.dotted(gapLength: 8),
);
// Fully custom — a repeating list of alternating on/off lengths, starting// with an "on" (drawn) segment. Here: long dash, gap, short dash, gap.ImageCompareSlider(
itemOne: constImage.asset('...'),
itemTwo: constImage.asset('...'),
dividerLineStyle: constDividerLineStyle(
pattern: <double>[12, 4, 4, 4],
strokeCap: StrokeCap.round,
),
);
Enable zoomable and/or pannable to pinch-zoom and drag both images at once
while keeping them perfectly aligned. Double-tap toggles zoom. Dragging the
handle still moves the slider, even while zoomed in.
Pass an ImageCompareSliderController to rotate either image in either
direction. Turn on lockRotation to rotate both images together in the same
cycle. The controller also exposes zoom, pan, position and a reset().
final controller = ImageCompareSliderController();
ImageCompareSlider(
controller: controller,
itemOne: constImage.asset('...'),
itemTwo: constImage.asset('...'),
);
// Rotate the left image a quarter turn clockwise.
controller.rotateOne(ImageCompareSliderController.quarterTurn);
// Rotate the right image counter-clockwise.
controller.rotateTwo(-ImageCompareSliderController.quarterTurn);
// Lock so both rotate together.
controller.lockRotation = true;
// Snap the second image to the first's angle.
controller.matchRotation();
// Reset zoom/pan/rotation.
controller.reset();
Remember to dispose() controllers you create yourself.
Custom handle ✋
Replace the painted handle with any widget via handleBuilder. It is centered
on the handle anchor and stays draggable. The divider line is still drawn.
If your images have different sizes or aspect ratios, set an aspectRatio and
a fit (e.g. BoxFit.cover) so both are forced into the same box and line up.
Releases are driven by the changelog using cider.
During development, record changes under the ## Unreleased section of
CHANGELOG.md (manually, or with dart run cider log added "...").
When ready, run the helper script. It bumps the version, promotes the
Unreleased section to the new version, commits and creates the v<version>
tag:
dart run tool/release.dart # patch release (default)
dart run tool/release.dart minor # or: major | patch | build | breaking | none
dart run tool/release.dart minor --push # cut and push in one step
By default it does not push. Push the tag to publish:
git push --follow-tags
You can also run the Release: … entries in the VS Code Run & Debug panel.
Pushing a version tag triggers .github/workflows/publish.yaml, which publishes
to pub.dev (via GitHub OIDC, no secrets) and creates a GitHub release with notes
from the matching CHANGELOG.md section.
One-time setup: on pub.dev go to the package admin page → Automated
publishing → enable GitHub Actions publishing for
cgutierr-zgz/image_compare_slider with the tag pattern v{{version}}.