Communitygithub.com

Flutter-Animationen

Umfassender Leitfaden für die Implementierung von Animationen in Flutter. Verwende ihn, wenn du Bewegung und visuelle Effekte zu Flutter-Apps hinzufügst: implizite Animationen (AnimatedContainer, AnimatedOpacity, TweenAnimationBuilder), explizite Animationen (AnimationController, Tween, AnimatedWidget/AnimatedBuilder), Hero-Animationen (Shared-Element-Übergänge), gestaffelte Animationen (sequentiell/überlappend) und physikbasierte Animationen. Enthält einen Workflow zur Auswahl des richtigen Animationstyps, Implementierungsmuster und Best Practices für Leistung und Benutzererfahrung.

Was ist Flutter-Animationen?

Dieses Skill ist ein vollständiger Leitfaden für die Implementierung von Animationen in Flutter, der für Entwickler konzipiert ist, die Flüssigkeit und visuelle Effekte in ihre Apps einbringen möchten. Es behandelt implizite Animationen wie `AnimatedContainer` und `AnimatedOpacity` für einfache, statusänderungsgesteuerte Bewegungen sowie explizite Animationen mit `AnimationController` und `Tween` für komplexe, anpassbare Abläufe. Darüber hinaus werden Hero-Animationen für geteilte Elementübergänge zwischen Bildschirmen, gestaffelte Animationen mit zeitlich versetzten Abläufen und physikbasierte Animationen mit `SpringSimulation` für natürliche Bewegungen erklärt. Das Skill ist plattformunabhängig, da es auf dem Flutter-Framework basiert, und bietet einen Entscheidungsbaum zur Auswahl des richtigen Animationstyps sowie Best Practices für Leistung und Benutzererfahrung, inklusive Tipps zur Vermeidung von Speicherlecks und zur Optimierung der Builds.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/madteacher/flutter-animations

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht Flutter-Animationen?

Überblick

Erstelle flüssige, leistungsstarke Animationen in Flutter mit dem richtigen Ansatz für jeden Anwendungsfall. Dieses Skill deckt den gesamten Animations-Workflow ab: von der Wahl zwischen impliziten und expliziten Ansätzen bis hin zur Implementierung komplexer Effekte wie Hero-Übergänge und gestaffelte Animationen.

Entscheidungsbaum für Animationstypen

Wähle den richtigen Animationstyp basierend auf deinen Anforderungen:

Implizite Animationen – Verwende sie, wenn:

  • Eine einzelne Eigenschaft animiert wird (Farbe, Größe, Position)
  • Die Animation durch eine Statusänderung ausgelöst wird
  • Keine feingranulare Kontrolle erforderlich ist

Explizite Animationen – Verwende sie, wenn:

  • Volle Kontrolle über den Animationslebenszyklus benötigt wird
  • Mehrere Eigenschaften gleichzeitig animiert werden
  • Auf Statusänderungen der Animation reagiert werden muss
  • Benutzerdefinierte Animationen oder Übergänge erstellt werden

Hero-Animationen – Verwende sie, wenn:

  • Ein Element zwischen zwei Bildschirmen geteilt wird
  • Shared-Element-Übergänge erstellt werden
  • Der Benutzer erwartet, dass ein Element zwischen Routen „fliegt“

Gestaffelte Animationen – Verwende sie, wenn:

  • Mehrere Animationen sequentiell oder überlappend ablaufen sollen
  • Ripple-Effekte oder sequentielle Enthüllungen erstellt werden
  • Listenelemente nacheinander animiert werden

Physikbasierte Animationen – Verwende sie, wenn:

  • Animationen natürlich/physikalisch wirken sollen
  • Federähnliches Verhalten, Scroll-Gesten
  • Ziehbare Interaktionen

Implizite Animationen

Implizite Animationen verwalten die Animation automatisch, wenn sich Eigenschaften ändern. Es wird kein Controller benötigt.

Häufige implizite Widgets

AnimatedContainer – Animiert mehrere Eigenschaften (Größe, Farbe, Dekoration, Padding):

AnimatedContainer(
  duration: const Duration(milliseconds: 300),
  curve: Curves.easeInOut,
  width: _expanded ? 200 : 100,
  height: _expanded ? 200 : 100,
  color: _expanded ? Colors.blue : Colors.red,
  child: const FlutterLogo(),
)

AnimatedOpacity – Einfache Einblend-Animation:

AnimatedOpacity(
  opacity: _visible ? 1.0 : 0.0,
  duration: const Duration(milliseconds: 300),
  child: const Text('Hello'),
)

TweenAnimationBuilder – Benutzerdefinierte Tween-Animation ohne Boilerplate:

TweenAnimationBuilder<double>(
  tween: Tween<double>(begin: 0, end: 1),
  duration: const Duration(seconds: 1),
  builder: (context, value, child) {
    return Opacity(
      opacity: value,
      child: Transform.scale(
        scale: value,
        child: child,
      ),
    );
  },
  child: const FlutterLogo(),
)

Weitere implizite Widgets:

  • AnimatedPadding – Padding-Animation
  • AnimatedPositioned – Positionsanimation (im Stack)
  • AnimatedAlign – Ausrichtungsanimation
  • AnimatedContainer – Mehrere Eigenschaften
  • AnimatedSwitcher – Überblenden zwischen Widgets
  • AnimatedDefaultTextStyle – Textstil-Animation

Best Practices

  • Bevorzuge implizite Animationen für einfache Fälle
  • Verwende passende Kurven für natürliche Bewegung (siehe Curves-Klasse)
  • Setze curve und duration für vorhersagbares Verhalten
  • Verwende den onEnd-Callback bei Bedarf
  • Vermeide verschachtelte implizite Animationen aus Leistungsgründen

Explizite Animationen

Explizite Animationen bieten volle Kontrolle mit AnimationController.

Kernkomponenten

AnimationController – Treibt die Animation an:

late AnimationController _controller;

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

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

Tween – Interpoliert zwischen Start- und Endwerten:

animation = Tween<double>(begin: 0, end: 300).animate(_controller);

CurvedAnimation – Wendet eine Kurve auf die Animation an:

animation = CurvedAnimation(
  parent: _controller,
  curve: Curves.easeInOut,
);

AnimatedWidget-Muster

Am besten geeignet für wiederverwendbare animierte Widgets:

class AnimatedLogo extends AnimatedWidget {
  const AnimatedLogo({super.key, required Animation<double> animation})
    : super(listenable: animation);

  @override
  Widget build(BuildContext context) {
    final animation = listenable as Animation<double>;
    return Center(
      child: Container(
        height: animation.value,
        width: animation.value,
        child: const FlutterLogo(),
      ),
    );
  }
}

AnimatedBuilder-Muster

Am besten geeignet für komplexe Widgets mit Animationen:

class GrowTransition extends StatelessWidget {
  const GrowTransition({
    required this.child,
    required this.animation,
    super.key,
  });

  final Widget child;
  final Animation<double> animation;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: AnimatedBuilder(
        animation: animation,
        builder: (context, child) {
          return SizedBox(
            height: animation.value,
            width: animation.value,
            child: child,
          );
        },
        child: child,
      ),
    );
  }
}

Überwachung des Animationsstatus

animation.addStatusListener((status) {
  switch (status) {
    case AnimationStatus.completed:
      _controller.reverse();
      break;
    case AnimationStatus.dismissed:
      _controller.forward();
      break;
    default:
      break;
  }
});

Mehrere gleichzeitige Animationen

class AnimatedLogo extends AnimatedWidget {
  const AnimatedLogo({super.key, required Animation<double> animation})
    : super(listenable: animation);

  static final _opacityTween = Tween<double>(begin: 0.1, end: 1);
  static final _sizeTween = Tween<double>(begin: 0, end: 300);

  @override
  Widget build(BuildContext context) {
    final animation = listenable as Animation<double>;
    return Center(
      child: Opacity(
        opacity: _opacityTween.evaluate(animation),
        child: Container(
          height: _sizeTween.evaluate(animation),
          width: _sizeTween.evaluate(animation),
          child: const FlutterLogo(),
        ),
      ),
    );
  }
}

Integrierte explizite Übergänge

Flutter bietet vorgefertigte Übergänge:

  • FadeTransition – Einblend-Animation
  • ScaleTransition – Skalierungsanimation
  • SlideTransition – Schiebeanimation
  • SizeTransition – Größenanimation
  • RotationTransition – Rotationsanimation
  • PositionedTransition – Positionsanimation (im Stack)

Beispiel:

FadeTransition(
  opacity: _animation,
  child: const FlutterLogo(),
)

Leistungstipps

  • Entsorge Controller, wenn das Widget entfernt wird
  • Verwende AnimatedBuilder für optimale Neuerstellungen
  • Vermeide setState() in Animations-Listenern (verwende AnimatedWidget/AnimatedBuilder)
  • Verwende timeDilation, um Animationen während des Debuggens zu verlangsamen

Hero-Animationen

Hero-Animationen erstellen Shared-Element-Übergänge zwischen Bildschirmen.

Einfache Hero-Animation

Quellbildschirm:

Hero(
  tag: 'hero-image',
  child: Image.asset('images/logo.png'),
)

Zielbildschirm:

Hero(
  tag: 'hero-image',  // Gleicher Tag!
  child: Image.asset('images/logo.png'),
)

Vollständiges Beispiel

class PhotoHero extends StatelessWidget {
  const PhotoHero({
    super.key,
    required this.photo,
    this.onTap,
    required this.width,
  });

  final String photo;
  final VoidCallback? onTap;
  final double width;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: width,
      child: Hero(
        tag: photo,
        child: Material(
          color: Colors.transparent,
          child: InkWell(
            onTap: onTap,
            child: Image.asset(photo, fit: BoxFit.contain),
          ),
        ),
      ),
    );
  }
}

Navigation zwischen Bildschirmen:

Navigator.of(context).push(
  MaterialPageRoute<void>(
    builder: (context) {
      return Scaffold(
        appBar: AppBar(title: const Text('Detail')),
        body: Center(
          child: PhotoHero(
            photo: 'images/logo.png',
            width: 300.0,
            onTap: () => Navigator.of(context).pop(),
          ),
        ),
      );
    },
  ),
);

Radiale Hero-Animation

Wandle während des Übergangs von einem Kreis in ein Rechteck um:

class RadialExpansion extends StatelessWidget {
  const RadialExpansion({
    super.key,
    required this.maxRadius,
    this.child,
  }) : clipRectSize = 2.0 * (maxRadius / math.sqrt2);

  final double maxRadius;
  final double clipRectSize;
  final Widget? child;

  @override
  Widget build(BuildContext context) {
    return ClipOval(
      child: Center(
        child: SizedBox(
          width: clipRectSize,
          height: clipRectSize,
          child: ClipRect(child: child),
        ),
      ),
    );
  }
}

Verwende mit MaterialRectCenterArcTween für zentrierte Interpolation:

static RectTween _createRectTween(Rect? begin, Rect? end) {
  return MaterialRectCenterArcTween(begin: begin, end: end);
}

Best Practices für Hero-Animationen

  • Verwende eindeutige, konsistente Tags (oft das Datenobjekt selbst)
  • Halte die Widget-Bäume des Hero-Widgets zwischen Routen ähnlich
  • Wickle Bilder in Material mit transparenter Farbe ein, um einen „Pop“-Effekt zu erzielen
  • Verwende timeDilation, um Übergänge zu debuggen
  • Erwäge HeroMode, um Hero-Animationen bei Bedarf zu deaktivieren

Gestaffelte Animationen

Führe mehrere Animationen mit unterschiedlichem Timing aus.

Einfache gestaffelte Animation

Alle Animationen teilen sich einen Controller:

class StaggerAnimation extends StatelessWidget {
  StaggerAnimation({super.key, required this.controller})
    : opacity = Tween<double>(begin: 0.0, end: 1.0).animate(
        CurvedAnimation(
          parent: controller,
          curve: const Interval(0.0, 0.100, curve: Curves.ease),
        ),
      ),
      width = Tween<double>(begin: 50.0, end: 150.0).animate(
        CurvedAnimation(
          parent: controller,
          curve: const Interval(0.125, 0.250, curve: Curves.ease),
        ),
      );

  final AnimationController controller;
  final Animation<double> opacity;
  final Animation<double> width;

  Widget _buildAnimation(BuildContext context, Widget? child) {
    return Container(
      alignment: Alignment.bottomCenter,
      child: Opacity(
        opacity: opacity.value,
        child: Container(
          width: width.value,
          height: 150,
          color: Colors.blue,
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: controller,
      builder: _buildAnimation,
    );
  }
}

Intervallbasiertes Timing

Jede Animation hat ein Intervall zwischen 0.0 und 1.0:

animation = Tween<double>(begin: 0, end: 300).animate(
  CurvedAnimation(
    parent: controller,
    curve: const Interval(
      0.25,  // Start bei 25% der Controller-Dauer
      0.50,  // Ende bei 50% der Controller-Dauer
      curve: Curves.ease,
    ),
  ),
);

Häufige Tweens

borderRadius = BorderRadiusTween(
  begin: BorderRadius.circular(4),
  end: BorderRadius.circular(75),
).animate(
  CurvedAnimation(
    parent: controller,
    curve: const Interval(0.375, 0.500, curve: Curves.ease),
  ),
);

Gestaffelte Menü-Animation

class _MenuState extends State<Menu> with SingleTickerProviderStateMixin {
  static const _initialDelayTime = Duration(milliseconds: 50);
  static const _itemSlideTime = Duration(milliseconds: 250);
  static const _staggerTime = Duration(milliseconds: 50);
  static const _buttonDelayTime = Duration(milliseconds: 150);
  static const _buttonTime = Duration(milliseconds: 500);

  final _animationDuration =
      _initialDelayTime +
      (_staggerTime * _menuTitles.length) +
      _buttonDelayTime +
      _buttonTime;

  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: _animationDuration,
      vsync: this,
    );
    _controller.forward();
  }

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

Best Practices für gestaffelte Animationen

  • Verwende Interval, um Animationen zeitlich zu versetzen
  • Stelle sicher, dass die Controller-Dauer alle Intervalle abdeckt
  • Verwende Kurven für natürliche Bewegung innerhalb der Intervalle
  • Erwäge timeDilation, um das Timing zu debuggen
  • Staffele Menüpunkte mit zunehmender Verzögerung für einen Ripple-Effekt

Physikbasierte Animationen

Erstelle natürlich wirkende Animationen mit Physiksimulationen.

Fling-Animation

_controller.fling(
  velocity: 2.0,  // Einheiten pro Sekunde
);

Benutzerdefinierte Physiksimulation

_controller.animateWith(
  SpringSimulation(
    spring: const SpringDescription(
      mass: 1,
      stiffness: 100,
      damping: 10,
    ),
    start: 0.0,
    end: 1.0,
    velocity: 0.0,
  ),
);

Häufige Physiksimulationen

  • SpringSimulation – Federphysik
  • BouncingScrollSimulation – Scrollen mit Springen
  • ClampingScrollSimulation – Scrollen ohne Springen
  • GravitySimulation – Schwerkraftbasiert

Best Practices

MACHEN

  • Entsorge AnimationController, wenn das Widget entsorgt wird
  • Verwende AnimatedBuilder/AnimatedWidget statt setState() in Listenern
  • Wähle passende Kurven für natürliche Bewegung
  • Verwende timeDilation zum Debuggen von Animationen
  • Berücksichtige die Leistung (vermeide schwere Widgets in Animations-Builds)
  • Teste Animationen auf verschiedenen Geräten
  • Unterstütze Rückwärtsanimationen für ein intuitives Gefühl

NICHT MACHEN

  • Vergiss nicht, AnimationController zu entsorgen (Speicherleck)
  • Verwende setState() in Animations-Listenern, wenn AnimatedBuilder ausreicht
  • Gehe nicht davon aus, dass die Animation sofort abgeschlossen ist (behandle AnimationStatus)
  • Überanimieren (Animationen können Benutzer ablenken)
  • Erstelle keine Animationen, die „ruckelig“ wirken (verwende glatte Kurven)
  • Ignoriere die Barrierefreiheit (respektiere die Einstellung disableAnimations)

Ressourcen

references/

implicit.md – Vollständige Referenz für implizite Animations-Widgets mit Beispielen und Best Practices.

explicit.md – Tiefergehende Erklärung von expliziten Animationen, AnimationController und Mustern.

hero.md – Leitfaden für Hero-Animationen mit Standard- und Radialübergängen.

staggered.md – Muster und Timingsstrategien für gestaffelte Animationen.

physics.md – Physikbasierte Animationen und Simulationen.

curves.md – Referenz für die Curves-Klasse und die Auswahl geeigneter Kurven.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

Verwandte Skills