Snap은 다양한 레이아웃에서 부드럽고 사용자 정의 가능한 스냅 동작을 가능하게 하는 포괄적인 Flutter 패키지입니다. 스냅 포인트, 이징 애니메이션 및 동적 조정에 대한 정밀한 제어를 지원하여 반응형이고 제스처 기반 인터페이스를 만들기에 적합합니다. 스크롤 가능한 위젯과 원활하게 통합되며 스냅 위치와 전환에 대해 세밀한 관리를 제공합니다. 고급 제스처 상호작용을 원하는 개발자를 위해 설계되었으며, 그리드 기반 또는 카드 유사 UI에서 사용자 경험을 향상시킵니다.
사용 사례
드래그 가능한 카드 레이아웃 만들기
스와이프-투-스냅 탐색 구현
반응형 그리드 인터페이스 구축
인터랙티브 슬라이더 설계
스냅 포인트를 사용한 부드러운 스크롤링 활성화
주요 기능
유연한 스냅 포인트 구성
사용자 정의 가능한 애니메이션 곡선
여러 스냅 타겟 지원
동적 스냅 조정
제스처 인식 스냅
크로스 플랫폼 호환성
적합한 대상
인터랙티브 UI를 구축하는 개발자
제스처 기반 탐색을 구현하는 디자이너
정밀한 위젯 정렬이 필요한 앱
스크롤 가능한 그리드 또는 캐러셀을 사용하는 프로젝트
사용자 인터랙션의 완성도에 집중하는 팀
고려 사항
복잡한 레이아웃의 경우 성능 최적화가 필요할 수 있습니다
기본 예제를 넘어서는 문서가 제한적입니다
여러 스냅 상태를 관리할 때 발생할 수 있는 복잡성
중소에서 대규모 프로젝트에 가장 적합
Flutter의 제스처 시스템에 대한 이해가 필요합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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!