搜索插件、代码仓与 APP 分类

page_route_animator 封面
插件详情v1.0.4

page_route_animator

Flutter 页面路由过渡包,包含 62 种不同的过渡效果。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
138
喜欢数
95
Pub 分数
160

安装插件

flutter pub add page_route_animator

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供 62 种内置页面路由过渡效果,以增强导航动画。它简化了跨平台动态且视觉上吸引人的屏幕过渡实现。开发者可以轻松应用预定义的动画效果,如滑动、淡入淡出、缩放和自定义效果,只需少量代码。该包支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上行为一致。非常适合旨在通过流畅且引人入胜的导航流程提升用户体验的应用。

适合场景

  • 通过流畅的过渡效果增强应用导航
  • 创建沉浸式的入门体验
  • 为标签页或屏幕切换添加视觉效果
  • 构建交互式教程
  • 使用动画导航设计现代用户界面
  • 通过动态过渡提升用户参与度

主要特点

  • 62 个预构建的过渡动画
  • 简单 API,配置直观
  • 跨平台兼容性
  • 可自定义的动画参数
  • 支持推送和弹出过渡
  • 轻量且易于集成

适合对象

  • 寻求丰富导航效果的Flutter开发者
  • 需要精心设计的入门或教程流程的应用程序
  • 设计师专注于用户体验和动态设计
  • 致力于现代、动画化用户界面的项目
  • 希望快速实现过渡而无需复杂编码的开发者

使用建议

  • 由于包含动画,可能会略微增加捆绑包大小
  • 某些高级动画在低端设备上可能需要性能调优
  • 对高度独特的过渡逻辑的自定义有限
  • 不适合优先考虑极简主义而非动画的应用程序
  • 需要理解 Flutter 的 Navigator 和路由系统

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Page Route Animator Package

Flutter page route transition package, with 62 different page transitions.

flutter platform pub package BSD-3-Clause effective dart

Examples

page_route_animator_20_transitions_p1 page_route_animator_20_transitions_p2 page_route_animator_20_transitions_p3

Getting Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  page_route_transition: ^1.0.4

Usage

To use this package you have to import it in your file by using below command:

import 'package:page_route_animator/page_route_animator.dart';

Code Example

import 'package:flutter/material.dart';
import 'package:page_route_animator/page_route_animator.dart';

void main(List<String> args) => runApp(const MyApp());

/// This widget is the root of your app.
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Page Route Animator Code Example',
      theme: ThemeData(primarySwatch: Colors.purple),
      home: const HomeScreen(),

      /// using onGenerateRoute
      onGenerateRoute: (settings) {

        switch (settings.name) {
          case '/second-screen':
            return PageRouteAnimator(
              child: const SecondScreen(),
              routeAnimation: RouteAnimation.topToBottom,
              settings: settings,
              curve: Curves.linear,
              duration: const Duration(milliseconds: 500),
              reverseDuration: const Duration(milliseconds: 500),
            );
          default:
            return null;
        }
      },
    );
  }
}

/// HomeScreen
class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('HomeScreen'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: ListView(
          children: [
            /// Push using onGenerateRoute
            /// Navigator.pushNamed()
            ElevatedButton(
              onPressed: () {
                Navigator.pushNamed(
                  context,
                  '/second-screen',
                  arguments: 'I am going',
                );
              },
              child: getText('Top To Bottom - onGenerateRoute'),
            ),

            /// Navigator.push()
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  PageRouteAnimator(
                    child: const SecondScreen(),
                    routeAnimation: RouteAnimation.bottomToTop,
                    settings: const RouteSettings(arguments: 'I am going'),
                    curve: Curves.slowMiddle,
                    duration: const Duration(milliseconds: 500),
                    reverseDuration: const Duration(milliseconds: 500),
                  ),
                );
              },
              child: getText('Bottom To Top'),
            ),

            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  PageRouteAnimator(
                    child: const SecondScreen(),
                    routeAnimation: RouteAnimation.leftToRight,
                    settings: const RouteSettings(arguments: 'I am going'),
                    curve: Curves.linear,
                  ),
                );
              },
              child: getText('Left To Right'),
            ),

            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  PageRouteAnimator(
                    child: const SecondScreen(),
                    routeAnimation: RouteAnimation.rightToLeft,
                    settings: const RouteSettings(arguments: 'I am going'),
                    curve: Curves.easeOut,
                  ),
                );
              },
              child: getText('Right To left'),
            ),

            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  PageRouteAnimator(
                    child: const SecondScreen(),
                    routeAnimation: RouteAnimation
                        .bottomRightToTopLeftWithFadeRotateAndScale,
                    settings: const RouteSettings(arguments: 'I am going'),
                    curve: Curves.easeOut,
                  ),
                );
              },
              child:
                  getText('BottomRight To TopLeft With Fade, Rotate And Scale'),
            ),
          ],
        ),
      ),
    );
  }
}

/// SecondScreen
class SecondScreen extends StatelessWidget {
  const SecondScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    String? argument = ModalRoute.of(context)?.settings.arguments as String?;
    return Scaffold(
      backgroundColor: Colors.yellow,
      appBar: AppBar(
        title: const Text('SecondScreen'),
      ),
      body: Center(
        child: Text(
          argument ?? 'No Data',
          style: const TextStyle(
            fontSize: 48.0,
            fontWeight: FontWeight.bold,
            color: Colors.black,
          ),
        ),
      ),
    );
  }
}

// Helper Widget
Widget getText(String text) {
  return Align(
    alignment: Alignment.centerLeft,
    child: Text(text),
  );
}

Types Of Transitions

  • topToBottom,
  • bottomToTop,
  • leftToRight,
  • rightToLeft,
  • fade,
  • rotate,
  • scale,
  • size,
  • sizeFromTop,
  • sizeFromBottom,
  • fadeAndRotate,
  • fadeAndScale,
  • rotateAndScale,
  • fadeRotateAndScale,
  • topToBottomJoined,
  • bottomToTopJoined,
  • leftToRightJoined,
  • rightToLeftJoined,
  • topLeftToBottomRight,
  • topRightToBottomLeft,
  • bottomLeftToTopRight,
  • bottomRightToTopLeft,
  • topToBottomWithFade,
  • bottomToTopWithFade,
  • leftToRightWithFade,
  • rightToLeftWithFade,
  • topLeftToBottomRightWithFade,
  • bottomLeftToTopRightWithFade,
  • bottomRightToTopLeftWithFade,
  • topRightToBottomLeftWithFade,
  • topToBottomWithRotation,
  • bottomToTopWithRotation,
  • leftToRightWithRotation,
  • rightToLeftWithRotation,
  • topLeftToBottomRightWithRotation,
  • bottomLeftToTopRightWithRotation,
  • bottomRightToTopLeftWithRotation,
  • topRightToBottomLeftWithRotation,
  • topToBottomWithFadeAndRotate,
  • bottomToTopWithFadeAndRotate,
  • leftToRightWithFadeAndRotate,
  • rightToLeftWithFadeAndRotate,
  • topLeftToBottomRightWithFadeAndRotate,
  • topRightToBottomLeftWithFadeAndRotate,
  • bottomLeftToTopRightWithFadeAndRotate,
  • bottomRightToTopLeftWithFadeAndRotate,
  • topToBottomWithScale,
  • bottomToTopWithScale,
  • leftToRightWithScale,
  • rightToLeftWithScale,
  • topLeftToBottomRightWithScale,
  • topRightToBottomLeftWithScale,
  • bottomLeftToTopRightWithScale,
  • bottomRightToTopLeftWithScale,
  • topToBottomWithFadeRotateAndScale,
  • bottomToTopWithFadeRotateAndScale,
  • leftToRightWithFadeRotateAndScale,
  • rightToLeftWithFadeRotateAndScale,
  • topLeftToBottomRightWithFadeRotateAndScale,
  • topRightToBottomLeftWithFadeRotateAndScale,
  • bottomLeftToTopRightWithFadeRotateAndScale,
  • bottomRightToTopLeftWithFadeRotateAndScale,

Curves

Learn about Curves from official docs, curves.

License

BSD 3-Clause

所属分类

源码仓库

使用此插件的项目

暂无相关数据。