Package selection guidance compiled from public package information, community data, and project usage.
Snap is a comprehensive Flutter package that provides flexible snapping capabilities for widgets, enabling smooth and customizable snapping behavior across various layouts. It supports precise control over snap points, easing animations, and dynamic adjustments, making it ideal for creating responsive, gesture-driven interfaces. The package integrates seamlessly with scrollable widgets and offers fine-grained management of snap positions and transitions. Designed for developers seeking advanced gesture interactions, Snap enhances user experience in grid-based or card-like UIs.
Use cases
Creating draggable card layouts
Implementing swipe-to-snap navigation
Building responsive grid interfaces
Designing interactive sliders
Enabling smooth scrolling with snap points
Key features
Flexible snap point configuration
Customizable animation curves
Support for multiple snap targets
Dynamic snap adjustment
Gesture-aware snapping
Cross-platform compatibility
Suitable for
Developers building interactive UIs
Designers implementing gesture-based navigation
Apps requiring precise widget alignment
Projects using scrollable grids or carousels
Teams focused on polished user interactions
Considerations
May require performance tuning for complex layouts
Limited documentation beyond basic examples
Potential complexity in managing multiple snap states
Best suited for medium to large-scale projects
Requires understanding of Flutter's gesture system
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
snap
An extensive snap tool/widget for Flutter that allows very flexible snap management and snapping between your widgets.
Inspired by WhatsApp's in-app Youtube player.
It is highly recommended to read the documentation and run the example project on a real device to fully understand and inspect the full range
of capabilities.
This is an extensive snap tool/widget for Flutter that allows very flexible snap management and snapping between your widgets.
Just wrap your snapper widget with the SnapController widget, fill the parameters, define your snappable widget and this package will take care
of everything else.
How-to-Use
"The view is what is being moved. It is the widget that snaps to the bound. The bound is what the view is being snapped to."
First, define two GlobalKeys- one for your view and one for your bound:
In this excerpt, the bound is an Align widget which expands through a Column widget.
The SnapController is confined between Offset.zero and Offset(1.0, 1.0). This means the view will not exceed the limits of the bound.
The flexibility is confined between Offset(0.75, 0.75) and Offset(0.75, 0.75). This means that the view can be moved beyond the horizontal/vertical
min/max constraints with a flexibility of 0.75 before it snaps.
The snapTargets determine from where and to where the view should snap once the movement is over. In this example:
The top left corner of the view can snap to the top left corner of the bound.
The top right corner of the view can snap to the top right corner of the bound.
The bottom left corner of the view can snap to the bottom left corner of the bound.
The bottom right corner of the view can snap to the bottom right corner of the bound.
The center of the view can snap to the center of the bound.
Keep in mind that these constant values are provided only for the ease of use. snapTargets can consist of any values you wish.
Use [SnapControllerState]'s [bool isMoved(double treshold)] method to determine if the view is moved or not where [treshold] is the distance at
which the view should be considered to be moved.
Notes
I started using and learning Flutter only some weeks ago so this package might have some parts that don't make sense, that should be completely
different, that could be much better, etc. Please let me know! Nicely!