AGENT SKILL

flutter-animating-apps

Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.

License 许可
MIT
最近更新
2026-06-13
Stars
★ 3
Forks
1

01 前言 Front Matter

name
flutter-animating-apps
description
Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.

03 SKILL.md 正文

Implementing Flutter Animations

Contents

Core Concepts

Manage Flutter animations using the core typed Animation system. Do not manually calculate frames; rely on the framework's ticker and interpolation classes.

  • Animation<T>: An abstract representation of a value that changes over time. It holds state (completed, dismissed) and notifies listeners, but knows nothing about the UI.
  • AnimationController: Drives the animation. Generates values (typically 0.0 to 1.0) tied to the screen refresh rate. Always provide a vsync (usually via SingleTickerProviderStateMixin). Always dispose() controllers to prevent memory leaks.
  • Tween<T>: A stateless mapping from an input range (usually 0.0-1.0) to an output type (e.g., Color, Offset, double). Chain tweens with curves using .animate().
  • Curve: Apply non-linear timing (e.g., Curves.easeIn, Curves.bounceOut) via CurvedAnimation or CurveTween.

Animation Strategies

  • Simple property changes (size, color, opacity) without playback control: Use Implicit Animations (AnimatedContainer, AnimatedOpacity, TweenAnimationBuilder).
  • Playback control (play, pause, reverse, loop) or coordinating multiple properties: Use Explicit Animations (AnimationController with AnimatedBuilder or AnimatedWidget).
  • Elements between two distinct routes: Use Hero Animations (Shared Element Transitions).
  • Real-world motion (snapping back after drag): Use Physics-Based Animations (SpringSimulation).
  • Sequence of overlapping or delayed motions: Use Staggered Animations (multiple Tweens with Interval curves on a single AnimationController).

Workflows

Implementing Implicit Animations

  • [ ] Identify target properties to animate (width, color, etc.).
  • [ ] Replace the static widget with its animated counterpart (AnimatedContainer, etc.).
  • [ ] Define the duration property.
  • [ ] (Optional) Define the curve property.
  • [ ] Trigger animation by updating properties inside setState().

Implementing Explicit Animations

  • [ ] Add SingleTickerProviderStateMixin to the State class.
  • [ ] Initialize AnimationController in initState() with vsync: this and duration.
  • [ ] Define Tween and chain to controller using .animate().
  • [ ] Wrap target UI in AnimatedBuilder.
  • [ ] Control playback: controller.forward(), .reverse(), .repeat().
  • [ ] Call controller.dispose() in dispose().

Implementing Hero Transitions

  • [ ] Wrap source widget in Hero with unique tag.
  • [ ] Wrap destination widget in Hero with the exact same tag.
  • [ ] Ensure widget trees inside both Heros are visually similar.
  • [ ] Trigger transition by pushing the destination route.

Implementing Physics-Based Animations

  • [ ] Set up AnimationController (no fixed duration).
  • [ ] Capture gesture velocity using GestureDetector (onPanEnd).
  • [ ] Instantiate SpringSimulation with mass, stiffness, damping, velocity.
  • [ ] Drive controller using controller.animateWith(simulation).

Examples

Example: Staggered Animation with AnimatedBuilder

class StaggeredAnimationDemo extends StatefulWidget {
  @override
  State<StaggeredAnimationDemo> createState() => _StaggeredAnimationDemoState();
}

class _StaggeredAnimationDemoState extends State<StaggeredAnimationDemo>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  late Animation<double> _widthAnimation;
  late Animation<Color?> _colorAnimation;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 2),
      vsync: this,
    );

    _widthAnimation = Tween<double>(begin: 50.0, end: 200.0).animate(
      CurvedAnimation(
        parent: _controller,
        curve: const Interval(0.0, 0.5, curve: Curves.easeIn),
      ),
    );

    _colorAnimation = ColorTween(begin: Colors.blue, end: Colors.red).animate(
      CurvedAnimation(
        parent: _controller,
        curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
      ),
    );

    _controller.forward();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: _controller,
      builder: (context, child) {
        return Container(
          width: _widthAnimation.value,
          height: 50.0,
          color: _colorAnimation.value,
        );
      },
    );
  }
}

Example: Custom Page Route Transition

Route createCustomRoute(Widget destination) {
  return PageRouteBuilder(
    pageBuilder: (context, animation, secondaryAnimation) => destination,
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      const begin = Offset(0.0, 1.0);
      const end = Offset.zero;
      const curve = Curves.easeOut;

      final tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
      final offsetAnimation = animation.drive(tween);

      return SlideTransition(position: offsetAnimation, child: child);
    },
  );
}

04 同仓库更多 Skills

openplaybooks-dev
openplaybooks-dev/converge

hello-checker

Use this skill when asked to "verify", "check", or "validate" a file's existence and content. It provides a reliable workflow for confirming files meet their spec.

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

ask-skill

暂无简介

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

html-review-artifact

Framework-wide guidance for crafting polished human-review artifacts as markdown or HTML

前端开发Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

converge-planning

Design a Converge playbook end-to-end. Use when the user says "plan a project", "design a playbook", "decompose into tasks", "scaffold a Converge workflow", "onboard to Converge", or asks how to write TASK.md / playbook.yml. Two entry points: plan a new playbook or update an existing one. Hand off to `/converge-control` after producing the playbook structure.

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

converge-control

Operate a Converge playbook end-to-end — start runs, monitor progress, narrow failures with `--select`, inspect runtime state, validate definitions, surgically reset subtrees, and stop stuck or orphaned runs. Use this skill whenever the user says "run my playbook", "execute this", "monitor the run", "converge failed", "the run is stuck", "retry failures", "babysit this playbook", "what's the status?", "show me the gantt", or asks how to use `converge run` / `--select` / `inspect` / `doctor` / `clean` / `stop`. Also use it for `HTTP 401` / `Invalid API key` failures on the first task — those are environment-not-playbook problems — and for any post-run cleanup work. Hand off to `converge-planning` if the user wants to design or restructure the playbook itself.

开发工程师Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

repair-taskts

Fix task.ts definition issues — Seed syntax, missing .build(), empty checks, import errors, TypeScript errors

开发工程师
★ 3