搜索分类、插件与代码仓

插件详情v0.0.3

phased

专注于动画的简化状态管理

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
991
喜欢数
6
Pub 分数
150

安装插件

flutter pub add phased

插件介绍

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

Phased 是一个 Flutter 包,通过专注于动画来简化状态管理。它使开发者能够以声明式且直观的方式管理状态转换,特别适用于依赖大量动画变化的 UI。通过将状态更新组织成阶段,它确保了跨小部件的平滑、协调的动画效果。该包与 Flutter 的动画系统无缝集成,并为复杂的基于状态的动画提供了清晰、易读的代码。

适合场景

  • 动画化UI状态转换
  • 管理多步骤用户流程
  • 创建交互式入门屏幕
  • 使用动态更新构建响应式仪表板
  • 在多个小部件之间同步动画

主要特点

  • 基于阶段的状态管理
  • 内置动画协调
  • 声明式语法用于状态变更
  • 轻量且最小化样板
  • 与 Flutter 动画框架的无缝集成

适合对象

  • 开发者优先考虑动画质量
  • 具有复杂状态驱动动画的项目
  • 寻求简单状态管理的团队
  • UI密集型应用,如引导流程或仪表板
  • Flutter 初学者学习动画模式

使用建议

  • 最适合以动画为中心的应用程序
  • 可能需要学习一种新的状态处理范式
  • 不适合大规模数据密集型应用
  • 除了基本示例外,文档有限
  • 需要了解 Flutter 的动画概念

原始 README

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

Phased

style: very good analysis License: MIT

Simplified state management focused on animations

Installation 💻

❗ In order to start using Phased you must have the Flutter SDK installed on your machine.

Add phased to your pubspec.yaml:

dependencies:
  phased:

Install it:

flutter packages get

Description

Phased is a simple state management meant to be used to build animations, its objective is to provide an easy, boilerplateless way to create and manage the state of an animation, so developers can focus on building the animations themselves.

The package consists of two classes: PhasedState, which describes the state and offers control methods for an animation, and Phased, an abstract Widget that will build the animation itself.

Example

To build a simple animation that blinks a child using opacity, the following code can be used:

class BlinkState extends PhasedState<bool> {
  BlinkState() : super(values: [true, false]);
}

class Blink extends Phased<bool> {
  const Blink({
    super.key,
    required super.state,
    required this.child,
  });

  final Widget child;

  @override
  Widget build(BuildContext context) {
    return AnimatedOpacity(
      opacity: state.phaseValue(
        values: const {true: 1},
        defaultValue: 0,
      ),
      onEnd: state.next,
      duration: const Duration(milliseconds: 250),
      child: child,
    );
  }
}

Then to use it:

Blink(
  state: BlinkState(),
  child: Container(
    width: 100,
    height: 100,
    color: Colors.blue,
  ),
);

For more complex examples, check the example folder.


所属分类

源码仓库

使用此插件的项目