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

circular_reveal_animation 封面
插件详情v2.0.2

circular_reveal_animation

圆形揭示动画作为Flutter组件!灵感来自Android的ViewAnimationUtils.createCircularReveal(...)。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
4300
喜欢数
271
Pub 分数
160

安装插件

flutter pub add circular_reveal_animation

插件介绍

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

一个 Flutter 小部件,可实现圆形揭示动画,灵感来自 Android 的 ViewAnimationUtils.createCircularReveal。它在目标小部件上创建平滑的扩展或收缩圆形效果,非常适合以自然流畅的动作揭示或隐藏内容。该动画与平台无关,可在 Android、iOS、Web、macOS、Windows 和 Linux 上正常工作。它可无缝集成到现有的 Flutter 应用中,以增强 UI 过渡和用户参与度。

适合场景

  • 通过波纹效果揭示隐藏内容
  • 使用关闭的圆形动画隐藏小部件
  • 创建具有动态揭示效果的交互式按钮
  • 通过动画入场效果增强启动画面
  • 设计具有流畅外观的模态对话框
  • 在导航过渡中添加视觉反馈

主要特点

  • 跨平台兼容性
  • 平滑且可自定义的圆形揭示
  • 支持展开和收缩动画
  • 与现有控件的轻松集成
  • 内置的动画时间控制
  • 与任何子 Widget 兼容

适合对象

  • 寻求引人入胜的过渡效果的UI设计师
  • 开发交互式 Flutter 应用的开发者
  • 需要 Material Design 风格动画的应用程序
  • 包含动态内容的项目会暴露出需求
  • 针对多个平台且行为一致的团队

使用建议

  • 性能可能因复杂的子部件而有所不同
  • 需要仔细定位以获得最佳视觉效果
  • 超出半径和中心点之外的自定义有限
  • 不适合高频动画
  • 可能需要额外的布局包装以实现全屏效果

原始 README

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

Circular Reveal Animation

pub package

Circular Reveal Animation as Flutter widget!

Inspired by Android's ViewAnimationUtils.createCircularReveal(...).

Статья с описанием (русский).

Article with description (english).

Demo web-site

Usage

CircularRevealAnimation(
  // @required
  child: Container(color: Colors.red),
  // @required [Animation<double>]
  animation: animation,
  // child's center if not specified
  centerAlignment: Alignment.centerRight,
  // 0 if not specified
  minRadius: 12,
  // distance from center to further child's corner if not specified
  maxRadius: 200,
);

Example

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'CRA Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  AnimationController animationController;
  Animation<double> animation;

  @override
  void initState() {
    super.initState();
    animationController = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 1000),
    );
    animation = CurvedAnimation(
      parent: animationController,
      curve: Curves.easeIn,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("CRA Demo"),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              MaterialButton(
                child: Text("show reveal dialog"),
                onPressed: () => showRevealDialog(context),
                color: Colors.amber,
              ),
              SizedBox(height: 16),
              CircularRevealAnimation(
                child: Image.asset('assets/ocv.jpg'),
                animation: animation,
//                centerAlignment: Alignment.centerRight,
                centerOffset: Offset(130, 100),
//                minRadius: 12,
//                maxRadius: 200,
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(onPressed: () {
        if (animationController.status == AnimationStatus.forward ||
            animationController.status == AnimationStatus.completed) {
          animationController.reverse();
        } else {
          animationController.forward();
        }
      }),
    );
  }

  Future<void> showRevealDialog(BuildContext context) async {
    showGeneralDialog(
      barrierLabel: "Label",
      barrierDismissible: true,
      barrierColor: Colors.black.withOpacity(0.5),
      transitionDuration: Duration(milliseconds: 700),
      context: context,
      pageBuilder: (context, anim1, anim2) {
        return Align(
          alignment: Alignment.bottomCenter,
          child: Container(
            child: Padding(
              padding: const EdgeInsets.all(12.0),
              child: Image.asset('assets/klimt.png'),
            ),
            margin: EdgeInsets.only(top: 50, left: 12, right: 12, bottom: 0),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(5),
            ),
          ),
        );
      },
      transitionBuilder: (context, anim1, anim2, child) {
        return CircularRevealAnimation(
          child: child,
          animation: anim1,
          centerAlignment: Alignment.bottomCenter,
        );
      },
    );
  }
}

所属分类

源码仓库

使用此插件的项目