Skip to main content

animation-player-animations

Use when embedding an interactive animation player widget with playback controls, scrubbing sliders, and duration indicators in Flutter apps or debug catalogs using animation_player.

跳到安装

来源信息

仓库
mono0926/animation_player
最近来源活动
2026年9月9日 03:10
检测到的 SKILL.md 语言
英语
星标
10
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
animation_player-animations
description
Use when embedding an interactive animation player widget with playback controls, scrubbing sliders, and duration indicators in Flutter apps or debug catalogs using animation_player.
# animation_player Animation Control Guide `animation_player` provides a ready-to-use player widget containing play/pause controls, a seekable progress slider, and duration counters for debugging or presenting Flutter animations (such as `AnimatedIcon`, custom transitions, or Lottie/Rive animations). ## Guidelines - **Mounting the Player**: - Wrap any animated widget inside `AnimationPlayer(builder: (context, animation) => ..., duration: Duration(...))`. - Pass the provided `Animation<double>` directly into widgets like `AnimatedIcon(progress: animation)` or custom `AnimatedBuilder` / `AnimatedWidget` implementations. - **Configuring Durations**: - Specify `duration: const Duration(...)` according to the target animation's full cycle. - Set `autoReset: true` if the animation should immediately jump back to time 0 upon reaching completion. - **Use Cases**: - Ideal for animation prototyping, widget catalog / Storybook showcases, design system review screens, and fine-tuning transition curves. ## Examples ### 1. Previewing AnimatedIcon Transitions ```dart import 'package:animation_player/animation_player.dart'; import 'package:flutter/material.dart'; class AnimatedIconPreviewScreen extends StatelessWidget { const AnimatedIconPreviewScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Animation Player Demo')), body: Center( child: Padding( padding: const EdgeInsets.all(24), child: AnimationPlayer( duration: const Duration(milliseconds: 1500), autoReset: false, builder: (context, animation) { return AnimatedIcon( icon: AnimatedIcons.menu_close, progress: animation, size: 96, color: Theme.of(context).colorScheme.primary, ); }, ), ), ), ); } } ``` ### 2. Custom Property Transition ```dart import 'package:animation_player/animation_player.dart'; import 'package:flutter/material.dart'; class CustomCardTransition extends StatelessWidget { const CustomCardTransition({super.key}); @override Widget build(BuildContext context) { return AnimationPlayer( duration: const Duration(seconds: 2), builder: (context, animation) { final curved = CurvedAnimation( parent: animation, curve: Curves.easeInOutBack, ); return ScaleTransition( scale: curved, child: Card( elevation: 8, child: Container( width: 180, height: 180, alignment: Alignment.center, child: const Text('Interactive Card'), ), ), ); }, ); } } ``` ## Common Pitfalls & Anti-Patterns - ❌ **Anti-pattern**: Creating a separate `AnimationController` alongside `AnimationPlayer`. - ✔️ **Correct**: Rely entirely on the `animation` object passed to `builder`, which is managed and synchronized with the UI scrubber automatically.
在 GitHub 查看