cupertino_will_pop_scope 패키지는 iOS 스타일의 네비게이션에서 페이지 전환 중에 onWillPop 콜백을 활성화함으로써 Flutter의 Cupertino 위젯을 확장합니다. 스와이프하여 뒤로 가기 제스처가 거부될 때 시각적 피드백을 제공하여 사용자 경험을 향상시키고, 더 부드럽고 직관적인 탐색을 보장합니다. 이 패키지는 폼 검증이나 저장되지 않은 변경 사항과 같은 사용자 정의 확인 로직이 필요한 앱에 특히 유용합니다. 기존의 CupertinoPageScaffold 및 CupertinoPageRoute 구현과 원활하게 통합됩니다.
사용 사례
이동 전에 저장되지 않은 변경 사항 처리
사용자 정의 뒤로 가기 제스처 검증
iOS 스타일 탐색에서 UX 개선
의도하지 않은 탐색 방지
뒤로 스와이프 시 확인 대화 상자 구현
스와이프 백 피드백 향상
주요 기능
Cupertino 전환에서 onWillPop 지원
거부된 스와이프 제스처에 대한 시각적 피드백
CupertinoPageScaffold 및 경로와 함께 작동
최소한의 보일러플레이트 통합
크로스 플랫폼 호환성
백 제스처 제어를 위한 깔끔한 API
적합한 대상
Cupertino 네비게이션을 사용한 iOS 스타일 앱
사용자 정의 뒤로 이동 탐색 로직이 필요한 앱
스와이프 백 UX 개선하는 개발자
팝 전에 확인이 필요한 프로젝트
일관된 모바일 탐색을 구축하는 팀
다중 플랫폼을 대상으로 하는 Flutter 앱
고려 사항
CupertinoPageScaffold 사용이 필요합니다
iOS 스타일의 탐색 패턴에 제한됨
다른 라우트 인터셉터와 충돌할 수 있습니다
마테리얼 디자인 앱에는 필요하지 않음
명시적인 백 핸들링과 함께 사용할 때 가장 좋습니다
Android 뒤로 가기 동작에 영향을 주지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
CupertinoWillPopScope
Note: This package can be used on any platform, and is not specific to iOS. ConditionalWillPopScope and CupertinoWillPopScopePageTransionsBuilder can each be used seprately.
CupertinoWillPopScopePageTransionsBuilder
The key to this package is a modified version of Flutter's CupertinoPageRoute, which has been enhanced with the following:
Visual feedback when users attempt to "swipe to go back" - the screen is allowed to be dragged a bit before it is snapped back to place.
If an enclosing route has willPop callbacks, they are triggered once the screen is snapped back to place.
ConditionalWillPopScope
When using this widget, be sure to update shouldAddCallbacks based on the state of your screen, and only set it to true when the screen should not be allowed to pop. Additionally, the onWillPop property should not be changed once set.
A working app using this package can be found in the example folder.
:warning: When using Flutter's WillPopScope widget, the onWillPop must be set conditionally. Otherwise, the "swipe to go back" gesture will be cancelled. In the example above, this is achieved by using _hasChanges as the condition.