v1.0.1page_animator
사용자 정의 효과를 제공하는 부드러운 페이지 전환 및 애니메이션을 제공하는 플러터 패키지입니다. 수평 페이지 탐색과 함께 매력적인 사용자 인터페이스를 만들기에 적합합니다.
StageCoding/page_animator open-source repository details.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A Flutter package that provides smooth page transitions and animations with customizable effects. Perfect for creating engaging user interfaces with horizontal page navigation.
The package supports various animation types through PageAnimatorType. Here's a comprehensive list of all available animations:
| Preview | Preview | Preview |
|---|---|---|
![]() |
![]() |
![]() |
Uncompressed gifanimatedSwitcher - Animated switcher transition |
Uncompressed gifnoAnimation - No animation effect, instant page switch |
Uncompressed gifhorizontalSimple - Simple horizontal slide transition |
![]() |
![]() |
![]() |
Uncompressed gifhorizontalFade - Horizontal slide with fade effect |
Uncompressed gifhorizontalFadeInverse - Horizontal slide with inverse fade effect |
Uncompressed gifverticalSimple - Simple vertical slide transition |
![]() |
![]() |
|
Uncompressed gifverticalFade - Vertical slide with fade effect |
Uncompressed gifverticalFadeInverse - Vertical slide with inverse fade effect |
You can change the animation type dynamically using the controller:
pageAnimatorController.type.value = PageAnimatorType.verticalFade;
Add this to your package's pubspec.yaml file:
dependencies:
page_animator: ^1.0.0
import 'package:page_animator/page_animator.dart';
PageAnimatorController:final pageAnimatorController = PageAnimatorController(
type: PageAnimatorType.horizontalFade,
);
PageAnimator widget:PageAnimator(
controller: pageAnimatorController,
onPageChanged: (int currentPage) {
print('Page offset: $currentPage');
},
leftMostIndex: -3,
rightMostIndex: 3,
children: [
// Your page widgets here
],
enableImmersiveSwitch: true,
)
The PageAnimator widget allows you to set bounds for page navigation using leftMostIndex and rightMostIndex parameters:
leftMostIndex: The minimum page offset that can be reached by swiping leftrightMostIndex: The maximum page offset that can be reached by swiping rightThese bounds can be changed in realtime, allowing you to dynamically control the navigation range. For example:
// Initially allow navigation indefinitelly
PageAnimator(
leftMostIndex: null,
rightMostIndex: null,
// ... other parameters
)
// Later, you can update the bounds
PageAnimator(
leftMostIndex: -3,
rightMostIndex: 3,
// ... other parameters
)
When a bound is reached, the page will stop scrolling in that direction, providing a natural end to the navigation.
Here's a complete example showing how to use the package:
class MyPage extends StatefulWidget {
@override
State<MyPage> createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
final pageAnimatorController = PageAnimatorController(
type: PageAnimatorType.horizontalFade,
);
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageAnimator(
controller: pageAnimatorController,
onPageChanged: (int currentPage) {
print('Page offset: $currentPage');
},
leftMostIndex: -3,
rightMostIndex: 3,
children: [
for (final page in List.generate(3, (index) => index))
_buildPage(page),
],
enableImmersiveSwitch: true,
),
);
}
Widget _buildPage(int page) {
return Scaffold(
body: Center(
child: Text('Page $page'),
),
floatingActionButton: FloatingActionButton(
onPressed: () => pageAnimatorController.animateToOffset(1),
child: const Icon(Icons.skip_next),
),
);
}
}
The PageAnimatorController provides several methods to control page transitions:
animateToOffset(int offset): Animate to a specific page offsettype: Change the animation type dynamicallyswitcherActive: Control the page switcher stateContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
children: List of widgets to display as pagesonPageChanged: Callback when page is changedleftMostIndex: The first page user can go torightMostIndex: The last page user can go tocontroller: PageAnimatorController instanceenableImmersiveSwitch: Optional boolean that controls whether to enable immersive mode while switcher is inactive, and automatically disable it when user enters switcher. If not specified, defaults to true.onDragStart: Optional callback when drag startsonDragEnd: Optional callback when drag endsonDragAnimationStart: Optional callback when animation startsonDragAnimationEnd: Optional callback when animation ends의존성 목록 4 개
{"sdk":"flutter"}^0.21.2^5.0.0{"sdk":"flutter"}사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗