搜尋套件、儲存庫與 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 應用的開發者
  • 需要材質設計風格動畫的應用程式
  • 具有動態內容的專案會揭示需求
  • 針對多個平台且行為一致的團隊

使用建議

  • 效能可能會因複雜的子組件而有所差異
  • 需要仔細定位以獲得最佳視覺效果
  • 超出半徑和中心點之外的自定義有限
  • 不適合高頻率動畫
  • 可能需要額外的佈局包裝以實現全螢幕效果

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

所屬分類

原始碼儲存庫

使用此套件的專案