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

thanos_snap_effect 封面
插件详情v0.0.9

thanos_snap_effect

高性能、高度可定制且易于使用的 Flutter 'Thanos Snap' 效果。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2430
喜欢数
54
Pub 分数
160

安装插件

flutter pub add thanos_snap_effect

插件介绍

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

The thanos_snap_effect 包为 Flutter 应用提供高性能、可自定义的“灭霸响指”动画。它使开发者能够轻松地在多个平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上实现标志性的响指效果——元素以戏剧性的方式消失。通过流畅的过渡和丰富的自定义选项,该包可增强游戏、交互式 UI 或趣味性应用功能的用户参与度。该包轻量级、文档完善,并以简单易用为设计目标,同时不牺牲灵活性。

适合场景

  • 游戏UI效果
  • 交互式应用动画
  • 有趣的用户界面
  • 数字叙事
  • 应用引导流程

主要特点

  • 高性能渲染
  • 跨平台支持
  • 可自定义的动画速度
  • 可配置的淡入淡出和缩放效果
  • 与现有控件的轻松集成
  • 对多种屏幕尺寸的支持

适合对象

  • 寻求趣味动画的 Flutter 开发者
  • 面向年轻受众的应用
  • 游戏化应用
  • UI/UX 设计师探索动态效果

使用建议

  • 可能不适合极简设计风格
  • 需要仔细把握时机以获得最佳用户体验
  • 不太适合对可访问性要求较高的界面
  • 性能在低端设备上可能有所不同

原始 README

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

High-performance, high-customizable, and easy-to-use "Thanos Snap" effect for Flutter.

Simple controller example      Animated list example

Getting started

IMPORTANT: This package uses the custom fragment shader, so you should include the shader file in your pubspec.yaml file.

flutter:
  shaders:
    - packages/thanos_snap_effect/shader/thanos_snap_effect.glsl

Usage

This package provides a 'Snappable' widget. The principle of using this widget is similar to "Transition" widgets, like "FadeTransition", "ScaleTransition", etc.

Just wrap your widget with the Snappable widget and pass the AnimationController (or any Animation descendant) object to the "animation" property. Then just start the animation and see the magic!

Snappable(
  animation: animationController, // AnimationController object, or any other animation object with double tween from 0.0 to 1.0
  child: MyWidget(), // Your widget that you want to animate
);

Check the example for more complex examples.

Customization

You can customize the effect by passing the "outerPadding" or "style" properties to the Snappable widget.

Snappable(
  animation: _animationController,
  child: MyWidget(),
  outerPadding: const EdgeInsets.all(40.0), // The padding around the widget where particles can appear. Default value is EdgeInsets.all(40.0) 
  style: SnappableStyle(
    particleLifetime: 0.6, // Lifetime of particle before it disappears. Default value is 0.6. Must be between 0.0 and 1.0
    fadeOutDuration: 0.3, // Duration of fade out animation of particle. Fade out effect starts in particleLifetime - fadeOutDuration and ends when particleLifetime ends. Default value is 0.3. Must be between 0.0 and particleLifetime
    particleSpeed: 1.0, // Speed of particles. Default value is 1.0
    particleSize: const SnappableParticleSize.squareFromRelativeWidth(0.01), // Size of 1 particle
  ),
);
Mastering the particleSize property

There are 2 ways to define the size of particles:

Relative to the size of the widget

SnappableParticleSize.relative(width: 0.01, height: 0.02) // 1% of the width and 2% of the height of the widget
SnappableParticleSize.squareFromRelativeWidth(0.01) // 1% of the width of the widget. The height will be calculated to keep the square shape
SnappableParticleSize.squareFromRelativeHeight(0.01) // 1% of the height of the widget. The width will be calculated to keep the square shape

Absolute size (in dp)

SnappableParticleSize.absoluteDp(width: 16, height: 8) // 16dp width and 8dp height

所属分类

源码仓库

使用此插件的项目