搜尋套件、儲存庫與 APP 分類

page_animator 封面
套件詳情v1.0.1

page_animator

一個提供流暢頁面過渡和動畫的 Flutter 套件,支援自訂效果。非常適合建立具有水平頁面導航的吸引人使用者介面。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
14
喜歡數
9
Pub 分數
160

安裝套件

flutter pub add page_animator

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

PageAnimator 是一個專為 Flutter 設計的套件,旨在為水平導航提供順暢、可自訂的頁面過渡與動畫效果。它透過流體視覺效果增強使用者介面,讓應用程式導航更富吸引力且直覺。適用於需要動態螢幕變換的應用情境,例如引導流程、儀表板或多重步驟流程。此套件支援所有主要平台,包含 Android、iOS、Web、macOS、Windows 及 Linux,確保跨裝置的一致性表現。

適用情境

  • 引導畫面
  • 儀表板導航
  • 多步驟表單
  • 互動式教學
  • 可滑動內容
  • 動畫標籤切換

主要特色

  • 可自訂的過渡效果
  • 平滑的水平頁面動畫
  • 跨平台相容性
  • 與 PageView 的輕鬆整合
  • 支援基於手勢的導航
  • 可設定的持續時間與曲線

適合對象

  • 尋求動畫導航的開發者
  • 具有可滑動介面的應用
  • 注重設計的UI實作
  • 具備豐富互動功能的行動與Web應用
  • 重視使用者體驗的團隊

使用建議

  • 可能影響複雜動畫的效能
  • 需要仔細調整以獲得最佳使用者體驗
  • 有限的內建預設(需自訂)
  • 不適合簡單的靜態頁面
  • 最適合中等動畫複雜度

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Page Animator

A Flutter package that provides smooth page transitions and animations with customizable effects. Perfect for creating engaging user interfaces with horizontal page navigation.

Features

  • Multiple animation types for page transitions, switchable in realtime
  • Infinite scrolling in both directions, with ability to set bounds in realtime
  • Animated switcher - tap on a page, and it will zoom out, similar to Kindle reader
  • Immersive mode support

Animation Types

The package supports various animation types through PageAnimatorType. Here's a comprehensive list of all available animations:

Preview Preview Preview
Uncompressed gif
animatedSwitcher - Animated switcher transition
Uncompressed gif
noAnimation - No animation effect, instant page switch
Uncompressed gif
horizontalSimple - Simple horizontal slide transition
Uncompressed gif
horizontalFade - Horizontal slide with fade effect
Uncompressed gif
horizontalFadeInverse - Horizontal slide with inverse fade effect
Uncompressed gif
verticalSimple - Simple vertical slide transition
Uncompressed gif
verticalFade - Vertical slide with fade effect
Uncompressed gif
verticalFadeInverse - Vertical slide with inverse fade effect

You can change the animation type dynamically using the controller:

pageAnimatorController.type.value = PageAnimatorType.verticalFade;

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  page_animator: ^1.0.0

Usage

  1. Import the package:
import 'package:page_animator/page_animator.dart';
  1. Create a PageAnimatorController:
final pageAnimatorController = PageAnimatorController(
  type: PageAnimatorType.horizontalFade,
);
  1. Use the PageAnimator widget:
PageAnimator(
  controller: pageAnimatorController,
  onPageChanged: (int currentPage) {
    print('Page offset: $currentPage');
  },
  leftMostIndex: -3,
  rightMostIndex: 3,
  children: [
    // Your page widgets here
  ],
  enableImmersiveSwitch: true,
)
Page Bounds

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 left
  • rightMostIndex: The maximum page offset that can be reached by swiping right

These 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.

Example

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),
      ),
    );
  }
}

Controller Methods

The PageAnimatorController provides several methods to control page transitions:

  • animateToOffset(int offset): Animate to a specific page offset
  • type: Change the animation type dynamically
  • switcherActive: Control the page switcher state

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Parameters

  • children: List of widgets to display as pages
  • onPageChanged: Callback when page is changed
  • leftMostIndex: The first page user can go to
  • rightMostIndex: The last page user can go to
  • controller: PageAnimatorController instance
  • enableImmersiveSwitch: 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 starts
  • onDragEnd: Optional callback when drag ends
  • onDragAnimationStart: Optional callback when animation starts
  • onDragAnimationEnd: Optional callback when animation ends

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。