### CMake Installation Rules for Application Bundle Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/windows/CMakeLists.txt Configures the installation process for the application, ensuring that support files are copied next to the executable. It sets the installation prefix, defines directories for data and libraries, and installs the main executable, ICU data, Flutter library, and bundled plugin libraries. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Tween Examples in Dart Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Provides examples of creating basic tweens for animating values like colors and doubles. These tweens define the start and end values for an animation. ```dart import 'package:flutter/material.dart'; // Animate a color from red to blue var colorTween = ColorTween(begin: Colors.red, end: Colors.blue); // Animate a double value from 0 to 100 var doubleTween = Tween(begin: 0.0, end: 100.0); ``` -------------------------------- ### CMake Installation Rules for Bundle Creation Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Configures installation rules to create a relocatable application bundle. It cleans the bundle directory, installs the executable, Flutter ICU data, Flutter library, bundled plugin libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Directory using CMake Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt This CMake code snippet installs the Flutter asset directory to the application's data directory. It first removes any existing directory to ensure a clean installation and then copies the contents of the specified Flutter asset directory. This is crucial for applications that rely on external assets managed by Flutter. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install( CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Animation Mixin Quickstart in Dart Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Illustrates how to use the AnimationMixin to automatically manage AnimationController instances. This reduces boilerplate code for animations in Flutter widgets. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class MyWidget extends StatefulWidget { const MyWidget({super.key}); @override _MyWidgetState createState() => _MyWidgetState(); } // Add AnimationMixin class _MyWidgetState extends State with AnimationMixin { late Animation size; @override void initState() { // The AnimationController instance `controller` is already wired up. // Just connect with it with the tweens. size = Tween(begin: 0.0, end: 200.0).animate(controller); controller.play(); // start the animation playback super.initState(); } @override Widget build(BuildContext context) { return Container( width: size.value, // use animated value height: size.value, color: Colors.red, ); } } ``` -------------------------------- ### Animating Multiple Properties with MovieTween in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md This example demonstrates how to animate multiple properties like width, height, and color simultaneously using MovieTween. It defines a sequence of animations and applies them to a Container. Dependencies include flutter/material.dart and simple_animations/simple_animations.dart. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { // Specify your tween final MovieTween tween = MovieTween() ..scene( begin: const Duration(milliseconds: 0), end: const Duration(milliseconds: 1000)) .tween('width', Tween(begin: 0.0, end: 100.0)) ..scene( begin: const Duration(milliseconds: 1000), end: const Duration(milliseconds: 1500)) .tween('width', Tween(begin: 100.0, end: 200.0)) ..scene( begin: const Duration(milliseconds: 0), duration: const Duration(milliseconds: 2500)) .tween('height', Tween(begin: 0.0, end: 200.0)) ..scene( begin: const Duration(milliseconds: 0), duration: const Duration(milliseconds: 3000)) .tween('color', ColorTween(begin: Colors.red, end: Colors.blue)); return MaterialApp( home: Scaffold( backgroundColor: Colors.white, body: Center( child: PlayAnimationBuilder( tween: tween, // Pass in tween duration: tween.duration, // Obtain duration builder: (context, value, child) { return Container( width: value.get('width'), // Get animated values height: value.get('height'), color: value.get('color'), ); }, ), ), ), ); } } ``` -------------------------------- ### AnimationMixin: Automatic Controller Management in Flutter Source: https://context7.com/felixblaschke/simple_animations/llms.txt Demonstrates how to use AnimationMixin to automatically manage an AnimationController within a StatefulWidget. It handles initialization, vsync, and disposal, simplifying animation setup. The example shows creating animated size and color properties using the default controller. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class AnimatedWidget extends StatefulWidget { const AnimatedWidget({super.key}); @override State createState() => _AnimatedWidgetState(); } class _AnimatedWidgetState extends State with AnimationMixin { late Animation size; late Animation color; @override void initState() { super.initState(); // Use the built-in controller (auto-managed) size = Tween(begin: 50.0, end: 200.0).animate(controller); color = ColorTween(begin: Colors.red, end: Colors.blue) .animate(CurvedAnimation(parent: controller, curve: Curves.easeInOut)); // Start mirroring animation with 2-second duration controller.mirror(duration: const Duration(seconds: 2)); } @override Widget build(BuildContext context) { return Container( width: size.value, height: size.value, color: color.value, ); } } // Multiple controllers example class MultiControllerWidget extends StatefulWidget { const MultiControllerWidget({super.key}); @override State createState() => _MultiControllerWidgetState(); } class _MultiControllerWidgetState extends State with AnimationMixin { late AnimationController rotationController; late AnimationController scaleController; late Animation rotation; late Animation scale; @override void initState() { super.initState(); // Create additional managed controllers rotationController = createController(); scaleController = createController(); rotation = Tween(begin: 0.0, end: 6.28).animate(rotationController); scale = Tween(begin: 0.5, end: 1.5).animate(scaleController); // Independent animation timings rotationController.loop(duration: const Duration(seconds: 3)); scaleController.mirror(duration: const Duration(seconds: 1)); } @override Widget build(BuildContext context) { return Transform.rotate( angle: rotation.value, child: Transform.scale( scale: scale.value, child: Container( width: 80, height: 80, color: Colors.purple, ), ), ); } } ``` -------------------------------- ### Movie Tween Quickstart in Dart Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates how to combine multiple tweens into a single MovieTween for complex animations. It shows sequential tweens, scene composition, and type-safe property definitions. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; // Simple staggered tween final tween1 = MovieTween() ..tween('width', Tween(begin: 0.0, end: 100), duration: const Duration(milliseconds: 1500), curve: Curves.easeIn) .thenTween('width', Tween(begin: 100, end: 200), duration: const Duration(milliseconds: 750), curve: Curves.easeOut); // Design tween by composing scenes final tween2 = MovieTween() ..scene( begin: const Duration(milliseconds: 0), duration: const Duration(milliseconds: 500)) .tween('width', Tween(begin: 0.0, end: 400.0)) .tween('height', Tween(begin: 500.0, end: 200.0)) .tween('color', ColorTween(begin: Colors.red, end: Colors.blue)) ..scene( begin: const Duration(milliseconds: 700), end: const Duration(milliseconds: 1200)) .tween('width', Tween(begin: 400.0, end: 500.0)); // Type-safe alternative final width = MovieTweenProperty(); final color = MovieTweenProperty(); final tween3 = MovieTween() ..tween(width, Tween(begin: 0.0, end: 100)) ..tween(color, ColorTween(begin: Colors.red, end: Colors.blue)); ``` -------------------------------- ### PlayAnimationBuilder with Delay in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Demonstrates how to use PlayAnimationBuilder to create an animation that starts after a specified delay. It uses a Tween to animate the width of a Container. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return PlayAnimationBuilder( tween: Tween(begin: 100.0, end: 200.0), duration: const Duration(seconds: 2), delay: const Duration(seconds: 1), curve: Curves.easeOut, builder: (context, value, child) { return Container( width: value, height: 50.0, color: Colors.orange, ); }, ); } } ``` -------------------------------- ### Handle Animation Lifecycle Callbacks in PlayAnimationBuilder (Flutter) Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates how to use 'onStarted' and 'onCompleted' callbacks to react to the animation's lifecycle events within PlayAnimationBuilder. This example prints messages to the debug console when the animation starts and completes. It requires flutter/material and simple_animations. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; var widget = PlayAnimationBuilder( // lifecycle callbacks onStarted: () => debugPrint('Animation started'), onCompleted: () => debugPrint('Animation complete'), tween: ColorTween(begin: Colors.red, end: Colors.blue), duration: const Duration(seconds: 5), builder: (context, value, _) => Container(color: value, width: 100, height: 100), ); ``` -------------------------------- ### Basic AnimationMixin Usage in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md This Flutter example demonstrates the fundamental use of AnimationMixin to animate a widget's size. It requires the simple_animations package. The code initializes an Animation variable and uses a Tween to define the animation range, which is then applied to the widget's width and height. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Page())); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return const Scaffold( body: SafeArea(child: Center(child: MyAnimatedWidget())) ); } } class MyAnimatedWidget extends StatefulWidget { const MyAnimatedWidget({super.key}); @override _MyAnimatedWidgetState createState() => _MyAnimatedWidgetState(); } // Add AnimationMixin to state class class _MyAnimatedWidgetState extends State with AnimationMixin { late Animation size; // Declare animation variable @override void initState() { // The controller is automatically provided by the mixin. // Connect tween and controller and store into animation variable. size = Tween(begin: 0.0, end: 200.0).animate(controller); // Start the animation playback controller.play(); super.initState(); } @override Widget build(BuildContext context) { return Container( width: size.value, // Use the value of the animation variable height: size.value, color: Colors.red, ); } } ``` -------------------------------- ### Animation Builder Quickstart - Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates the usage of PlayAnimationBuilder, LoopAnimationBuilder, and MirrorAnimationBuilder for creating various animation effects like resizing, rotating, and color fading within stateless widgets. These builders simplify animation control and integration. ```dart import 'dart:math'; import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class ResizeCubeAnimation extends StatelessWidget { const ResizeCubeAnimation({super.key}); @override Widget build(BuildContext context) { // PlayAnimationBuilder plays animation once return PlayAnimationBuilder( tween: Tween(begin: 100.0, end: 200.0), // 100.0 to 200.0 duration: const Duration(seconds: 1), // for 1 second builder: (context, value, _) { return Container( width: value, // use animated value height: value, color: Colors.blue, ); }, onCompleted: () { // do something ... }, ); } } class RotatingBox extends StatelessWidget { const RotatingBox({super.key}); @override Widget build(BuildContext context) { // LoopAnimationBuilder plays forever: from beginning to end return LoopAnimationBuilder( tween: Tween(begin: 0.0, end: 2 * pi), // 0° to 360° (2π) duration: const Duration(seconds: 2), // for 2 seconds per iteration builder: (context, value, _) { return Transform.rotate( angle: value, // use value child: Container(color: Colors.blue, width: 100, height: 100), ); }, ); } } class ColorFadeLoop extends StatelessWidget { const ColorFadeLoop({super.key}); @override Widget build(BuildContext context) { // MirrorAnimationBuilder plays forever: alternating forward and backward return MirrorAnimationBuilder( tween: ColorTween(begin: Colors.red, end: Colors.blue), // red to blue duration: const Duration(seconds: 5), // for 5 seconds per iteration builder: (context, value, _) { return Container( color: value, // use animated value width: 100, height: 100, ); }, ); } } ``` -------------------------------- ### Basic AnimationMixin Usage in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates the fundamental pattern of using AnimationMixin in a StatefulWidget. It automatically manages an AnimationController, simplifying animation setup. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class MyAnimatedWidget extends StatefulWidget { const MyAnimatedWidget({super.key}); @override _MyAnimatedWidgetState createState() => _MyAnimatedWidgetState(); } // Add AnimationMixin to state class class _MyAnimatedWidgetState extends State with AnimationMixin { late Animation size; @override void initState() { size = Tween(begin: 0.0, end: 200.0).animate(controller); controller.play(); super.initState(); } @override Widget build(BuildContext context) { return Container(width: size.value, height: size.value, color: Colors.red); } } ``` -------------------------------- ### MirrorAnimationBuilder for Bidirectional Animations in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Demonstrates the use of MirrorAnimationBuilder to create animations that move back and forth. This example translates a Container horizontally. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return MirrorAnimationBuilder( tween: Tween(begin: -100.0, end: 100.0), // value for offset x-coordinate duration: const Duration(seconds: 2), curve: Curves.easeInOutSine, // non-linear animation builder: (context, value, child) { return Transform.translate( offset: Offset(value, 0), // use animated value for x-coordinate child: child, ); }, child: Container( width: 100, height: 100, color: Colors.green, ), ); } } ``` -------------------------------- ### Multiple AnimationController Instances in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md This Flutter example showcases how to manage multiple AnimationController instances for independent animation of widget properties like width, height, and color. It utilizes the simple_animations package and requires defining separate controllers and animations for each property. The code demonstrates mirroring animation behavior for continuous loops. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Page())); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return const Scaffold( body: SafeArea(child: Center(child: MyAnimatedWidget())) ); } } class MyAnimatedWidget extends StatefulWidget { const MyAnimatedWidget({super.key}); @override _MyAnimatedWidgetState createState() => _MyAnimatedWidgetState(); } class _MyAnimatedWidgetState extends State with AnimationMixin { // declare AnimationControllers late AnimationController widthController; late AnimationController heightController; late AnimationController colorController; // declare Animation variables late Animation width; late Animation height; late Animation color; @override void initState() { // create controller instances and use mirror animation behavior widthController = createController() ..mirror(duration: const Duration(seconds: 5)); heightController = createController() ..mirror(duration: const Duration(seconds: 3)); colorController = createController() ..mirror(duration: const Duration(milliseconds: 1500)); // connect tween with individual controllers width = Tween(begin: 100.0, end: 200.0).animate(widthController); height = Tween(begin: 100.0, end: 200.0).animate(heightController); color = ColorTween(begin: Colors.red, end: Colors.blue) .animate(colorController); super.initState(); } @override Widget build(BuildContext context) { return Container( width: width.value, // use animated values height: height.value, color: color.value, ); } } ``` -------------------------------- ### LoopAnimationBuilder for Repeating Animations in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Shows how to use LoopAnimationBuilder to create an animation that repeats indefinitely. This example scales a Text widget up and down. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return LoopAnimationBuilder( tween: Tween(begin: 0.0, end: 10.0), duration: const Duration(seconds: 2), curve: Curves.easeOut, builder: (context, value, child) { return Transform.scale( scale: value, child: child, ); }, child: const Text('Hello!'), ); } } ``` -------------------------------- ### CustomAnimationBuilder for Pulsing Square in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Illustrates how to use CustomAnimationBuilder for a fully customizable animation. This example creates a pulsing square with various animation properties. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return CustomAnimationBuilder( control: Control.mirror, tween: Tween(begin: 100.0, end: 200.0), duration: const Duration(seconds: 2), delay: const Duration(seconds: 1), curve: Curves.easeInOut, startPosition: 0.5, animationStatusListener: (status) { debugPrint('status updated: $status'); }, builder: (context, value, child) { return Container( width: value, height: value, color: Colors.blue, child: child, ); }, child: const Center( child: Text('Hello!', style: TextStyle(color: Colors.white, fontSize: 24))), ); } } ``` -------------------------------- ### CMake Installation of Native Assets and Flutter Assets Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/windows/CMakeLists.txt Installs native assets and Flutter assets to the application bundle. It ensures that the assets directory is fully re-copied on each build to prevent stale files and installs the AOT library for non-Debug builds. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Cross-Building Setup Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Configures CMake for cross-building by setting the system root and adjusting find root path modes when a Flutter target platform sysroot is specified. This ensures correct library and include path resolution. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Conditional AOT Library Installation in CMake Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt This CMake code snippet conditionally installs the Ahead-Of-Time (AOT) compiled library. The installation only occurs if the CMAKE_BUILD_TYPE is not 'Debug'. This is a common optimization to ensure release builds have the necessary performance libraries while development builds might not require them. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Enable Developer Mode with AnimationMixin Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md This example shows how to enable developer mode when using the AnimationMixin. By calling `enableDeveloperMode(controller)` within the `initState` method, the animation controller is connected to the AnimationDeveloperTools for debugging. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: Scaffold( body: SafeArea( // put DevTools very high in the widget hierarchy child: AnimationDeveloperTools( child: Center( child: MyAnimation(), ), ), ), ), ); } } class MyAnimation extends StatefulWidget { const MyAnimation({super.key}); @override _MyAnimationState createState() => _MyAnimationState(); } class _MyAnimationState extends State with AnimationMixin { late Animation size; @override void initState() { size = Tween(begin: 0.0, end: 100.0).animate(controller); enableDeveloperMode(controller); // enable developer mode controller.forward(); super.initState(); } @override Widget build(BuildContext context) { return Container(width: size.value, height: size.value, color: Colors.blue); } } ``` -------------------------------- ### Stateful Animation with CustomAnimationBuilder in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md This example shows how to use CustomAnimationBuilder within a stateful widget to manage animation control. It allows toggling the animation direction by interacting with a button. Dependencies include flutter/material.dart and simple_animations/simple_animations.dart. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatefulWidget { const Page({super.key}); @override _PageState createState() => _PageState(); } class _PageState extends State { Control control = Control.play; // state variable @override Widget build(BuildContext context) { return CustomAnimationBuilder( duration: const Duration(seconds: 1), control: control, // bind state variable to parameter tween: Tween(begin: -100.0, end: 100.0), builder: (context, value, child) { return Transform.translate( // animation that moves childs from left to right offset: Offset(value, 0), child: child, ); }, child: MaterialButton( // there is a button color: Colors.yellow, onPressed: toggleDirection, // clicking button changes animation direction child: const Text('Swap'), ), ); } void toggleDirection() { // toggle between control instructions setState(() { control = (control == Control.play) ? Control.playReverse : Control.play; }); } } ``` -------------------------------- ### Add Absolute Scenes to MovieTween Timeline Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Illustrates how to add scenes at specific points in a MovieTween's timeline using `tween.scene()`. It shows examples of defining scenes by specifying `begin`, `duration`, and `end` times. ```dart final tween = MovieTween(); // start at 0ms and end at 1500ms final scene1 = tween.scene( duration: const Duration(milliseconds: 1500), ); // start at 200ms and end at 900ms final scene2 = tween.scene( begin: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 700), ); // start at 700ms and end at 1400ms final scene3 = tween.scene( begin: const Duration(milliseconds: 700), end: const Duration(milliseconds: 1400), ); // start at 1000ms and end at 1600ms final scene4 = tween.scene( duration: const Duration(milliseconds: 600), end: const Duration(milliseconds: 1600), ); ``` -------------------------------- ### Enable Developer Mode with PlayAnimationBuilder Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md This example demonstrates how to enable developer mode for the PlayAnimationBuilder widget by setting the `developerMode` parameter to `true`. This connects the animation to the AnimationDeveloperTools widget for enhanced debugging capabilities. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: MyPage()))); class MyPage extends StatelessWidget { const MyPage({super.key}); @override Widget build(BuildContext context) { return SafeArea( // put DevTools very high in the widget hierarchy child: AnimationDeveloperTools( child: Center( child: PlayAnimationBuilder( tween: Tween(begin: 0.0, end: 100.0), duration: const Duration(seconds: 1), developerMode: true, // enable developer mode builder: (context, value, child) { return Container( width: value, height: value, color: Colors.blue, ); }, ), ), ), ); } } ``` -------------------------------- ### Flutter Library and Dependency Setup (CMake) Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/flutter/CMakeLists.txt Configures the Flutter library and its associated headers. It finds PkgConfig modules for GTK, GLIB, and GIO, sets paths for the Flutter library and ICU data, and defines an INTERFACE library target for Flutter, including necessary include directories and link libraries. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Basic Usage of AnimationDeveloperTools in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates the basic setup for using the AnimationDeveloperTools widget in a Flutter application. The widget should be placed high in the widget tree, wrapping the UI elements that contain animations to be debugged. This widget provides tools for step-by-step animation review. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; class MyPage extends StatelessWidget { const MyPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( // put DevTools very high in the widget hierarchy body: AnimationDeveloperTools( child: Container(), // your UI ), ); } } ``` -------------------------------- ### Add Delay to PlayAnimationBuilder Animation in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Shows how to introduce a delay before an animation starts using the 'delay' property in PlayAnimationBuilder. This example delays the color animation by 2 seconds. It depends on flutter/material and simple_animations. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; var widget = PlayAnimationBuilder( tween: ColorTween(begin: Colors.red, end: Colors.blue), duration: const Duration(seconds: 5), delay: const Duration(seconds: 2), // add delay builder: (context, value, _) { return Container( color: value, width: 100, height: 100, ); }, ); ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Initializes the CMake project, sets the minimum required version, and defines the project name and supported languages. It also configures executable and application identifiers, and sets modern CMake policies. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "sa_flutter_app") set(APPLICATION_ID "com.example.sa_flutter_app") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Link Libraries and Include Directories (CMake) Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/windows/runner/CMakeLists.txt This CMake snippet configures the necessary library dependencies and include paths for the application target. It links against the 'flutter' and 'flutter_wrapper_app' libraries, includes 'dwmapi.lib' for Windows-specific functionality, and sets the source directory as an include directory. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Set Animation Start Position - Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Shows how to set a custom starting position for an animation in Flutter using the `startPosition` parameter of `CustomAnimationBuilder`. The `startPosition` can be any value between 0.0 (beginning) and 1.0 (end) of the animation's duration. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; var widget = CustomAnimationBuilder( control: Control.play, startPosition: 0.5, // set start position at 50% duration: const Duration(seconds: 5), tween: ColorTween(begin: Colors.red, end: Colors.blue), builder: (context, value, child) { return Container(color: value, width: 100, height: 100); }, ); ``` -------------------------------- ### CMake Standard Build Settings Function Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, warnings, optimization levels, and definitions to targets. It enables C++14, sets Wall and Werror, applies O3 optimization for non-Debug builds, and NDEBUG for non-Debug builds. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### CMake Flutter and GTK Integration Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Integrates Flutter and system-level dependencies. It adds the Flutter managed directory as a subdirectory, finds and checks PkgConfig modules for GTK, and defines the application ID as a preprocessor macro. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Define Executable Target and Source Files (CMake) Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/windows/runner/CMakeLists.txt This CMake snippet defines the main executable target for the application, named by the BINARY_NAME variable. It lists all the source files, resource files, and generated files required to build the executable. Any new source files should be added here. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Non-Linear Animation with PlayAnimationBuilder in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Illustrates a non-linear animation using PlayAnimationBuilder in Flutter, specifically applying an easeOut curve. This makes the animation slow down towards the end, creating a smoother visual effect. The example animates the size of a pink square. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return PlayAnimationBuilder( tween: Tween(begin: 0.0, end: 200.0), duration: const Duration(seconds: 2), curve: Curves.easeOut, builder: (context, value, child) { return Container( width: value, height: value, color: Colors.pink, ); }, ); } } ``` -------------------------------- ### AnimationController Shortcuts in Dart Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Shows the usage of convenience methods added as extensions to the AnimationController class. These methods simplify common animation playback patterns like playing forward, reverse, looping, and mirroring, each accepting an optional duration parameter. This reduces boilerplate code for animation control. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void someFunction(AnimationController controller) { controller.play(duration: const Duration(milliseconds: 1500)); controller.playReverse(duration: const Duration(milliseconds: 1500)); controller.loop(duration: const Duration(milliseconds: 1500)); controller.mirror(duration: const Duration(milliseconds: 1500)); } ``` -------------------------------- ### CMake Project and Build Configuration Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/windows/CMakeLists.txt Sets up the minimum CMake version, project name, executable name, and defines build configuration types (Debug, Profile, Release). It also configures settings for the Profile build mode and enables Unicode support. ```cmake cmake_minimum_required(VERSION 3.14) project(sa_flutter_app LANGUAGES CXX) set(BINARY_NAME "sa_flutter_app") cmake_policy(VERSION 3.14...3.25) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Create Scenes Implicitly and Explicitly with MovieTween Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates the creation of scenes within a MovieTween, showcasing both implicit methods like `tween()` and `thenTween()`, and explicit methods like `scene()` and `thenFor()`. ```dart final tween = MovieTween(); // implicit scenes final sceneA1 = tween.tween('x', Tween(begin: 0.0, end: 1.0), duration: const Duration(milliseconds: 700)); final sceneA2 = sceneA1.thenTween('x', Tween(begin: 1.0, end: 2.0), duration: const Duration(milliseconds: 500)); // explicit scenes final sceneB1 = tween .scene(duration: const Duration(milliseconds: 700)) .tween('x', Tween(begin: 0.0, end: 1.0)); final sceneB2 = sceneA1 .thenFor(duration: const Duration(milliseconds: 500)) .tween('x', Tween(begin: 1.0, end: 2.0)); ``` -------------------------------- ### Animate Single Properties with tween() Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Explains how to animate a single property within a scene using the `tween()` method. This example shows animating 'width' and 'color' properties. ```dart final tween = MovieTween(); final scene = tween.scene(end: const Duration(seconds: 1)); scene.tween('width', Tween(begin: 0.0, end: 100.0)); scene.tween('color', ColorTween(begin: Colors.red, end: Colors.blue)); ``` -------------------------------- ### MovieTween Basic Usage - Builder Syntax Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates a more concise builder-style syntax for creating a MovieTween with multiple tweens using the '..' operator in Dart. This reduces verbosity when defining animations. ```dart final tween = MovieTween() ..tween('width', Tween(begin: 0.0, end: 100.0), duration: const Duration(milliseconds: 700)) ..tween('height', Tween(begin: 100.0, end: 200.0), duration: const Duration(milliseconds: 700)); ``` -------------------------------- ### CMake Executable Target Definition Source: https://github.com/felixblaschke/simple_animations/blob/main/example/sa_flutter_app/linux/CMakeLists.txt Defines the main executable target for the application, including source files like main.cc, my_application.cc, and generated plugin registration code. It applies standard build settings and links necessary libraries. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### MovieTween with PlayAnimationBuilder Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Demonstrates how to use MovieTween with Flutter's PlayAnimationBuilder to animate properties like 'width' and 'height' in Dart. The builder accesses animated values using the `get()` method. ```dart @override Widget build(BuildContext context) { // create tween var tween = MovieTween() ..scene(duration: const Duration(milliseconds: 700)) .tween('width', Tween(begin: 0.0, end: 100.0)) .tween('height', Tween(begin: 300.0, end: 200.0)); return PlayAnimationBuilder( tween: tween, // provide tween duration: tween.duration, // total duration obtained from MovieTween builder: (context, value, _) { return Container( width: value.get('width'), // get animated width value height: value.get('height'), // get animated height value color: Colors.yellow, ); }, ); } ``` -------------------------------- ### Apply Non-linear Motion with Curves in PlayAnimationBuilder (Flutter) Source: https://github.com/felixblaschke/simple_animations/blob/main/README.md Illustrates how to apply non-linear motion to an animation using the 'curve' property in PlayAnimationBuilder. This example uses Curves.easeInOut for a smoother animation effect. It requires flutter/material and simple_animations. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; var widget = PlayAnimationBuilder( tween: ColorTween(begin: Colors.red, end: Colors.blue), duration: const Duration(seconds: 5), curve: Curves.easeInOut, // specify curve builder: (context, value, _) { return Container( color: value, width: 100, height: 100, ); }, ); ``` -------------------------------- ### PlayAnimationBuilder with Child Widget in Flutter Source: https://github.com/felixblaschke/simple_animations/blob/main/example/example.md Shows how to use a child widget with PlayAnimationBuilder in Flutter. The child widget is passed to the builder function and can be incorporated within the animated widget. This allows for static content to be present while other properties animate. ```dart import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; void main() => runApp(const MaterialApp(home: Scaffold(body: Center(child: Page())))); class Page extends StatelessWidget { const Page({super.key}); @override Widget build(BuildContext context) { return PlayAnimationBuilder( tween: Tween(begin: 50.0, end: 200.0), duration: const Duration(seconds: 5), child: const Center(child: Text('Hello!')), // pass in static child builder: (context, value, child) { return Container( width: value, height: value, color: Colors.green, child: child, // use child inside the animation ); }, ); } } ```