### Install Application Executable Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Installs the application executable to the root of the installation prefix. This is part of the runtime component installation. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library File Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Installs the main Flutter library file to the lib directory of the bundle. This is a core runtime dependency. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Installation Prefix for Bundle Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Configures the installation prefix, typically setting it to a bundle directory within the build directory for relocatable deployments. ```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() ``` -------------------------------- ### Clean Build Bundle Directory on Install Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Installs a code snippet that removes the contents of the build bundle directory before installation, ensuring a clean state. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Iterates through a list of bundled libraries (likely from plugins) and installs them to the lib directory of the bundle. This ensures plugin dependencies are available. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Declarative Syntax with Animate Widget in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Illustrates the declarative approach to animations using the `Animate` widget. Shows how to define effects in a list, with an example equivalent to the chained syntax. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Declarative syntax with explicit effects list Widget declarativeAnimation = Animate( effects: [ FadeEffect(duration: 300.ms), ScaleEffect(duration: 300.ms), ], child: Text("Hello World!"), ); // Equivalent to chained syntax Widget equivalentChained = Text("Hello World!") .animate() .fade(duration: 300.ms) .scale(duration: 300.ms); ``` -------------------------------- ### CMake: Installation Rules for Runtime Components Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/CMakeLists.txt Defines installation rules for the application executable, ICU data, Flutter library, bundled plugin libraries, and assets. It ensures that all necessary files are correctly placed for the application to run, especially when running from Visual Studio. Dependencies include defined variables like BINARY_NAME, INSTALL_BUNDLE_DATA_DIR, and FLUTTER_ASSET_DIR_NAME. ```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() 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) ``` -------------------------------- ### Basic Widget Animation with Flutter Animate Source: https://context7.com/gskinner/flutter_animate/llms.txt Demonstrates basic fade and scale animations applied to a Text widget using the fluent `.animate()` extension method. Includes examples of chained effects and sequential application. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Basic fade and scale animation Widget basicAnimation = Text("Hello World!") .animate() .fade(duration: 300.ms) .scale(); // Fade in from 0 to full opacity over 500ms Widget fadeInExample = Text("Welcome") .animate() .fadeIn(duration: 500.ms); // Slide down and fade in sequentially Widget sequentialEffects = Text("Sequential") .animate() .fadeIn(duration: 500.ms) .scale(delay: 500.ms); // runs after fade completes ``` -------------------------------- ### Install ICU Data File Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory of the bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Re-copy Assets Directory on Install Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Installs code to remove and then copy the assets directory. This ensures that the latest assets are included in the bundle and prevents stale files. ```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) ``` -------------------------------- ### Install AOT library conditionally using CMake Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Conditionally installs an Ahead-of-Time compiled library when the build type is not Debug. This optimization is commonly used in Flutter release builds to exclude debugging libraries. Requires CMAKE_BUILD_TYPE, AOT_LIBRARY, and INSTALL_BUNDLE_LIB_DIR variables to be properly set before execution. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Duration Extensions for Flutter Animate Source: https://context7.com/gskinner/flutter_animate/llms.txt Showcases the convenient duration extensions provided by Flutter Animate for defining time intervals in milliseconds, seconds, minutes, hours, and days. Includes an example of their usage within an animation. ```dart import 'package:flutter_animate/flutter_animate.dart'; // Duration extensions for numbers Duration milliseconds = 200.ms; Duration seconds = 2.seconds; Duration minutes = 1.5.minutes; Duration hours = 2.hours; Duration days = 3.days; // Use in animations Widget example = Text("Timed") .animate() .fade(duration: 600.ms) .scale(delay: 300.ms, duration: 1.seconds); ``` -------------------------------- ### Drive Animations with ValueNotifierAdapter in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt This example shows how to control animations using a ValueNotifier. The ValueNotifierAdapter bridges the gap between a ValueNotifier and the flutter_animate animation system, allowing UI elements like sliders to directly drive animations. It requires the 'flutter_animate' and 'flutter/material.dart' packages. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; class ValueNotifierExample extends StatefulWidget { @override _ValueNotifierExampleState createState() => _ValueNotifierExampleState(); } class _ValueNotifierExampleState extends State { final ValueNotifier _progress = ValueNotifier(0.0); @override void dispose() { _progress.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Column( children: [ Slider( value: _progress.value, onChanged: (value) => _progress.value = value, ), Container( width: 200, height: 200, color: Colors.purple, ).animate( adapter: ValueNotifierAdapter( _progress, begin: 0.0, end: 1.0, animated: true, // smoothly animate changes ), ).scale().fadeIn(), ], ); } } ``` -------------------------------- ### Animation Delay in Flutter Animate Source: https://context7.com/gskinner/flutter_animate/llms.txt Demonstrates how to apply an initial delay to an entire animation sequence using the `delay` parameter in the `.animate()` method. This delay affects the start of the animation, not subsequent loops. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Delay applies once at start, not on loops Widget delayedAnimation = Text("Delayed Start") .animate( delay: 1000.ms, // waits 1 second before starting onPlay: (controller) => controller.repeat(), ) .fadeIn(delay: 500.ms) // this delay happens each loop .scale(); ``` -------------------------------- ### Configure Global Animation Defaults in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt This example demonstrates how to set global default animation durations and curves using 'Animate.defaultDuration' and 'Animate.defaultCurve'. It also shows how to enable 'Animate.restartOnHotReload' for development convenience. Animations defined without explicit duration or curve will inherit these global defaults. Requires 'flutter_animate' and 'flutter/material.dart'. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; void main() { // Configure global defaults Animate.defaultDuration = Duration(milliseconds: 400); Animate.defaultCurve = Curves.easeInOut; // Enable hot reload animation restart during development Animate.restartOnHotReload = true; runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // All animations now use 400ms and easeInOut by default return MaterialApp( home: Scaffold( body: Column( children: [ Text("Uses 400ms") .animate() .fadeIn(), // inherits default duration Text("Custom 1s") .animate() .fadeIn(duration: 1.seconds), // overrides default ], ), ), ); } } ``` -------------------------------- ### Link Libraries to Application Target Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Links the 'flutter' library and the PkgConfig-found GTK library to the application executable. This makes Flutter's core functionality and GTK available to the application. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Configure Flutter Library and Headers (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/flutter/CMakeLists.txt Sets up the Flutter library path, headers, and ICU data file. It defines an INTERFACE library target 'flutter' for linking and includes necessary directories. Dependencies are set to 'flutter_assemble'. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # 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/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/" ) add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Execute Flutter Tool Backend for Assembly (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom command to invoke the Flutter tool backend script for assembly. This is intended to run every time due to a phony output file. It sets up the environment and executes the script with specific arguments for Windows x64 and the current build configuration. The output targets include the Flutter library and headers. ```cmake # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) ``` -------------------------------- ### Find and Check GTK+ 3.0 Package Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Uses PkgConfig to find and check for the GTK+ 3.0 library, making its include directories and libraries available for linking. This is a system-level dependency. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Define Standard Build Settings Function Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt A CMake function to apply common compilation features, warnings, optimization levels, and definitions to a target. This promotes consistency across build targets. ```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() ``` -------------------------------- ### Define Project and Minimum CMake Version Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Sets the minimum required CMake version and defines the project name. This is a standard CMake initialization. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) ``` -------------------------------- ### Define Application Executable Target Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files. This includes the main C++ file, application-specific C++ files, and generated plugin registrant code. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Configure Modern CMake Behaviors and RPATH Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Opts into modern CMake behaviors to avoid warnings and sets the runtime search path for bundled libraries relative to the binary. This ensures libraries are found at runtime. ```cmake cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Build Flutter C++ Wrapper Library (Plugin) (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/flutter/CMakeLists.txt Compiles the C++ wrapper sources required for a Flutter plugin. It defines a STATIC library target 'flutter_wrapper_plugin', applies standard settings, sets visibility to 'hidden', links against the 'flutter' library, and includes specific header directories. It also depends on 'flutter_assemble'. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Include Generated Plugin CMake Rules Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Includes the CMake rules for building generated plugins. This allows plugins to be compiled and linked into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Animation with Initial Delay and Looping in Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Shows how to apply an initial delay to an entire animation sequence using the `Animate` widget's `delay` parameter and how to set up a repeating animation using `onPlay`. ```dart Text("Hello").animate( delay: 1000.ms, // this delay only happens once at the very start onPlay: (controller) => controller.repeat(), // loop ).fadeIn(delay: 500.ms) // this delay happens at the start of each loop ``` -------------------------------- ### Build Flutter C++ Wrapper Library (App Runner) (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/flutter/CMakeLists.txt Compiles the C++ wrapper sources needed for the Flutter application runner. It creates a STATIC library target 'flutter_wrapper_app', links it to the 'flutter' library, and specifies include directories. This target also depends on 'flutter_assemble'. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Include Flutter Managed Directory Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Includes the Flutter managed directory, typically containing generated build rules and source files. This is essential for integrating Flutter's build system. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Set Runtime Output Directory for Executable Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Configures the output directory for the executable to a subdirectory within the build directory. This is done to ensure correct relative paths for bundled resources. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Shorthand Widget Animation with Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Shows the chainable extension method syntax for applying animations to widgets. This shorthand simplifies the code by allowing effects to be chained directly after the `.animate()` call. ```dart Text("Hello World!").animate().fade().scale() ``` -------------------------------- ### Define CMake Project (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/runner/CMakeLists.txt This section defines the CMake project, sets the minimum required CMake version, and specifies the programming languages used. It also defines the application target and adds source files to it. ```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" ) ``` -------------------------------- ### Set Application Binary Name and ID Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Configures the name of the application's executable and its unique GTK application identifier. These are crucial for the application's identity and runtime behavior. ```cmake set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") ``` -------------------------------- ### CMake: Project-Level Configuration Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/CMakeLists.txt Sets up the minimum CMake version, project name, and binary name. It also configures build types for multi-configuration generators and standard build types for single-configuration generators. Dependencies include CMake version 3.14 or higher. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(SET CMP0063 NEW) 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() ``` -------------------------------- ### Android Build Configuration Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/flutter/CMakeLists.txt Defines Android compilation settings, build variants, and dependency management for Flutter applications. Controls the Android-specific aspects of the build process including version handling and optimization settings. ```gradle apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { namespace "io.flutter.app" compileSdkVersion 28 buildToolsVersion "28.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { applicationId "io.flutter.app" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" } buildTypes { release { signingConfig signingConfigs.debug } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } ``` ```dart android { namespace "io.flutter.app" compileSdkVersion 28 buildToolsVersion "28.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { applicationId "io.flutter.app" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" } } ``` -------------------------------- ### CMake: Profile Build Mode Settings Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/CMakeLists.txt Defines linker and compiler flags specifically for the 'Profile' build configuration, mirroring settings from the 'Release' configuration. This ensures consistent performance tuning for profiled builds. ```cmake 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}") ``` -------------------------------- ### CMake: Apply Standard Build Settings Function Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/CMakeLists.txt A CMake function to apply common compilation features and options to a target. It enforces C++17, sets warning levels, enables exceptions, and defines debug macros based on the build configuration. Input is a target name. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Link Libraries and Include Directories (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/runner/CMakeLists.txt Links the application target with necessary libraries and specifies include directories for header files. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Create Reusable Animation Effect Libraries in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Demonstrates how to create a static class to hold collections of predefined animation effects (e.g., fade, slide, scale, shimmer, shake). These libraries promote consistency and reusability across different widgets and the entire application. It utilizes the 'flutter_animate' package for defining effects. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Global effects library class AppAnimations { static final List fadeInUp = [ FadeEffect(duration: 300.ms, curve: Curves.easeOut), SlideEffect( begin: Offset(0, 0.2), end: Offset.zero, duration: 300.ms, curve: Curves.easeOut, ), ]; static final List scaleIn = [ ScaleEffect( begin: Offset(0.8, 0.8), end: Offset(1, 1), duration: 250.ms, curve: Curves.easeInOut, ), FadeEffect(duration: 250.ms), ]; static final List shimmerLoad = [ ShimmerEffect( duration: 1500.ms, color: Color(0xFF80DDFF), ), ]; static final List errorShake = [ ShakeEffect(duration: 400.ms, hz: 5, offset: Offset(8, 0), rotation: 0), TintEffect(color: Colors.red, end: 0.3, duration: 200.ms), ]; } // Use shared effects throughout app Widget loginButton = ElevatedButton( onPressed: () {}, child: Text("Login"), ).animate(effects: AppAnimations.scaleIn); Widget errorMessage = Text( "Invalid password", style: TextStyle(color: Colors.red), ).animate(effects: AppAnimations.errorShake); Widget loadingCard = Card( child: Container( height: 100, child: Text("Loading..."), ), ).animate( onPlay: (controller) => controller.repeat(), effects: AppAnimations.shimmerLoad, ); // Combine multiple effect sets Widget complexEntry = Container( padding: EdgeInsets.all(16), child: Text("Welcome"), ).animate(effects: AppAnimations.fadeInUp) .then() .animate(effects: AppAnimations.shimmerLoad); ``` -------------------------------- ### Animation Control with Callbacks in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Control animation lifecycles in flutter_animate using callbacks like onPlay, onComplete, and onInit. These allow for responsive animations, such as looping, executing code upon completion, or setting initial animation states. Requires flutter_animate. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Loop animation with onPlay Widget loopingAnimation = Text("Pulsing") .animate( onPlay: (controller) => controller.repeat(reverse: true), ) .fadeOut(curve: Curves.easeInOut); // Execute code when animation completes Widget withCompletion = Text("Completed") .animate( onComplete: (controller) { print("Animation finished!"); // Could navigate, show dialog, etc. }, ) .fadeIn() .scale(); // Initialize animation state Widget initAnimation = Text("Initialized") .animate( autoPlay: false, onInit: (controller) { controller.value = 0.5; // start at 50% // Store controller reference if needed }, ) .fadeIn(); // Manually control animation AnimationController? _controller; Widget manualControl = Text("Manual") .animate( autoPlay: false, onInit: (controller) { _controller = controller; }, ) .fadeIn() .scale(); // Later: _controller?.forward() ``` -------------------------------- ### Apply Fade and Scale Effects in Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates how to apply multiple animation effects to a widget using the `Animate` widget and specifying effects in a list. This is the declarative approach. ```dart Animate( effects: [FadeEffect(), ScaleEffect()], child: Text("Hello World!"), ) ``` -------------------------------- ### CMake: Include Flutter Build Rules Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/CMakeLists.txt Includes the CMake build rules for Flutter's managed directory and the application runner. It also includes generated plugin build rules, enabling the integration of Flutter libraries and plugins into the project build. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Apply Standard Build Settings (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be removed if custom build settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Dart: Control animations with callbacks Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates using animation callbacks like `onPlay` to manipulate the animation controller. The controller can be used for repeating, reversing, or other advanced playback controls. `CallbackEffect` and `ListenEffect` offer more granular control. ```dart Text("Horrible Pulsing Text") .animate(onPlay: (controller) => controller.repeat(reverse: true)) .fadeOut(curve: Curves.easeInOut) ``` -------------------------------- ### Dart: Create sequential animations with delays Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates chaining animations with delays using the `.then()` method. The `delay` parameter specifies the time after the previous animation finishes before the next one begins. ```dart Text("Hello").animate() .fadeIn(duration: 600.ms) .then(delay: 200.ms) // baseline=800ms .slide() ``` -------------------------------- ### Effect Timing and Sequencing in Flutter Animate Source: https://context7.com/gskinner/flutter_animate/llms.txt Explains how effects inherit timing properties like duration and curve when not explicitly defined. Demonstrates sequencing effects using `delay` and the `ThenEffect` for simplified sequential timing. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Effects inherit duration and curve from previous effect Widget inheritedTiming = Text("Inherited") .animate() .fadeIn(duration: 500.ms, curve: Curves.easeOut) .scale() // inherits 500ms duration and easeOut curve .slide(); // also inherits from scale // Using delay to sequence effects Widget sequencedEffects = Text("Sequenced") .animate() .fade(duration: 500.ms) .scale(delay: 500.ms, duration: 400.ms) // starts after fade .blur(delay: 900.ms); // starts after scale // First effect uses defaults if not specified Widget withDefaults = Text("Defaults") .animate() .fadeIn(); // uses Animate.defaultDuration (300ms) // ThenEffect establishes new baseline time Widget sequentialWithThen = Text("Sequential") .animate() .fadeIn(duration: 600.ms) .then(delay: 200.ms) // baseline is now 800ms (600 + 200) .slide() // starts at 800ms .then() // baseline is now slide's end time .scale(); // starts immediately after slide // Without ThenEffect, delays are relative to start Widget withoutThen = Text("Manual Timing") .animate() .fadeIn(duration: 600.ms) .slide(delay: 800.ms) // manual calculation needed .scale(delay: 1200.ms); // manual calculation needed ``` -------------------------------- ### Define Flutter Assembly Custom Target (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/flutter/CMakeLists.txt Creates a custom target 'flutter_assemble' that depends on the Flutter library, its headers, and all wrapper source files. This target ensures that the assembly process is triggered when needed. ```cmake # === Flutter tool backend === # ... (previous custom_command definition) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Sequential Effects with Delay in Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Illustrates how to sequence animation effects using the `delay` parameter. Effects run in parallel by default, but delays allow for sequential execution, with subsequent effects inheriting parameters if not specified. ```dart Text("Hello").animate() .fade(duration: 500.ms) .scale(delay: 500.ms) // runs after fade. ``` -------------------------------- ### Add Dependencies to Flutter Assemble (CMake) Source: https://github.com/gskinner/flutter_animate/blob/main/example/windows/runner/CMakeLists.txt Adds a dependency to the `flutter_assemble` target, ensuring that the Flutter tool portions of the build are executed. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Custom Effect Builder Animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Create unique animated effects in Flutter using the `custom` effect builder in flutter_animate. This allows for animations based on custom values, transitions, and widget compositions, such as animating padding, background colors, countdowns, and rotations. Requires the flutter_animate package. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Animate custom padding Widget customPadding = Text("Padded") .animate() .custom( duration: 1000.ms, begin: 0, end: 40, builder: (context, value, child) => Padding( padding: EdgeInsets.all(value), child: child, ), ); // Background color transition Widget colorTransition = Text("Hello World") .animate() .custom( duration: 800.ms, builder: (context, value, child) => Container( color: Color.lerp(Colors.red, Colors.blue, value), padding: EdgeInsets.all(8), child: child, ), ); // Countdown timer without child widget Widget countdown = Animate() .custom( duration: 10.seconds, begin: 10, end: 0, builder: (context, value, child) => Text( value.round().toString(), style: TextStyle(fontSize: 48), ), ) .fadeOut(); // Custom rotation with builder Widget customRotation = Container( width: 100, height: 100, color: Colors.orange, ).animate() .custom( duration: 2.seconds, begin: 0, end: 1, builder: (context, value, child) => Transform.rotate( angle: value * 6.28, // full rotation child: child, ), ); ``` -------------------------------- ### Dart: Create custom animated effects with CustomEffect Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates using `CustomEffect` to build custom animations by providing a `builder` function. This function receives a context, animation value, and child widget, allowing for complex visual changes like color transitions or custom rendering. ```dart Text("Hello World").animate().custom( duration: 300.ms, builder: (context, value, child) => Container( color: Color.lerp(Colors.red, Colors.blue, value), padding: EdgeInsets.all(8), child: child, // child is the Text widget being animated ) ) ``` ```dart Animate().custom( duration: 10.seconds, begin: 10, end: 0, builder: (_, value, __) => Text(value.round()), ).fadeOut() ``` -------------------------------- ### Shimmer Effect Animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Implement shimmer and loading effects using gradient overlays with flutter_animate. Supports basic shimmer, repeating animations, custom colors, blend modes, and custom angles. Requires the flutter_animate package. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Basic shimmer effect Widget basicShimmer = Text( "Loading...", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ).animate() .shimmer(duration: 1200.ms); // Repeating shimmer for loading state Widget loadingShimmer = Text( "Please Wait", style: TextStyle(fontSize: 20), ).animate(onPlay: (controller) => controller.repeat()) .shimmer(duration: 1200.ms, color: Color(0xFF80DDFF)); // Custom shimmer colors and blend mode Widget customShimmer = Container( width: 200, height: 100, color: Colors.grey[300], ).animate() .shimmer( duration: 1500.ms, colors: [Colors.transparent, Colors.white, Colors.transparent], blendMode: BlendMode.srcOver, ); // Shimmer with custom angle Widget angledShimmer = Text("Angled Shimmer") .animate(onPlay: (controller) => controller.repeat()) .shimmer( duration: 1000.ms, angle: 0.5, size: 1.5, ); ``` -------------------------------- ### Dart: Animate lists with intervals and effects Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Shows how to animate lists of widgets using `AnimateList` or the shorthand list extension. The `interval` parameter controls the delay between each child's animation, and `effects` define the animation to be applied. ```dart Column(children: AnimateList( interval: 400.ms, effects: [FadeEffect(duration: 300.ms)], children: [Text("Hello"), Text("World"), Text("Goodbye")], )) ``` ```dart Column( children: [Text("Hello"), Text("World"), Text("Goodbye")] .animate(interval: 400.ms).fade(duration: 300.ms), ) ``` -------------------------------- ### Set Build Type if Undefined Source: https://github.com/gskinner/flutter_animate/blob/main/example/linux/CMakeLists.txt Automatically sets the build type to 'Debug' if it hasn't been specified, ensuring a default build configuration. It also restricts the allowed values for CMAKE_BUILD_TYPE. ```cmake 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() ``` -------------------------------- ### Dart: Swap widgets during animation with SwapEffect Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates using `SwapEffect` to replace the target widget at a specific point in an animation. This is useful for transitioning between different widgets or creating sequential visual effects by swapping back the original widget. ```dart Text("Before").animate() .swap(duration: 900.ms, builder: (_, __) => Text("After")) ``` ```dart text.animate().fadeOut(300.ms) // fade out & then... // swap in original widget & fade back in via a new Animate: .swap(builder: (_, child) => child.animate().fadeIn()) ``` -------------------------------- ### Dart: Apply animated shaders to widgets Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Shows how to apply animated GLSL fragment shaders to widgets using `ShaderEffect`. This allows for advanced visual effects directly on the widget's rendering. Shaders can be combined with other animation effects. ```dart myWidget.animate() .shader(duration: 2.seconds, shader: myShader) .fadeIn(duration: 300.ms) // shader can be combined with other effects ``` -------------------------------- ### Implement fade effect animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Applies opacity transitions to widgets using the Flutter Animate package. Supports fade-in, fade-out, and custom fade ranges with configurable duration and easing curves. Requires flutter_animate package dependency. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Fade in from transparent to opaque Widget fadeIn = Text("Fade In") .animate() .fadeIn(duration: 600.ms); // Fade out from opaque to transparent Widget fadeOut = Text("Fade Out") .animate() .fadeOut(duration: 600.ms); // Custom fade range Widget customFade = Text("Custom") .animate() .fade(begin: 0.2, end: 0.8, duration: 500.ms); // Fade in with custom curve Widget curvedFade = Text("Smooth") .animate() .fadeIn(duration: 800.ms, curve: Curves.easeInOut); ``` -------------------------------- ### Tint Effect Animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Apply animated color tints to Flutter widgets using flutter_animate. This includes fading tints, partial strength tints, tint in/out sequences, and dark overlay effects. Requires the flutter_animate package. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Fade in a blue tint Widget blueTint = Image.asset('photo.jpg') .animate() .tint(color: Colors.blue, duration: 1.seconds); // Partial tint at 50% strength Widget partialTint = Image.asset('landscape.jpg') .animate() .tint(color: Colors.red, end: 0.5, duration: 800.ms); // Animate tint in then out Widget tintInOut = Container( width: 200, height: 200, color: Colors.white, child: Text("Tinted"), ).animate() .tint(color: Colors.purple, end: 0.7, duration: 500.ms) .untint(delay: 1000.ms, duration: 500.ms); // Dark overlay effect Widget darkOverlay = Image.asset('bright.jpg') .animate() .tint(color: Colors.black, end: 0.4, duration: 600.ms); ``` -------------------------------- ### Dart: Reuse animation effects globally Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Illustrates how immutable `Effect` instances can be reused across the application for consistent animations. This is useful for design systems and centralizing effect definitions. ```dart MyGlobalEffects.transitionIn = [ FadeEffect(duration: 100.ms, curve: Curves.easeOut), ScaleEffect(begin: 0.8, curve: Curves.easeIn) ] // then: Text('Hello').animate(effects: MyGlobalEffects.transitionIn) ``` -------------------------------- ### Apply blur effect animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Applies Gaussian blur effects to widgets with support for directional blurring, uniform blur, and custom blur intensities. Includes blur-in and blur-out transitions. Requires flutter_animate package dependency. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Blur in (sharp to blurred) Widget blurIn = Image.asset('photo.jpg') .animate() .blur(begin: Offset(0, 0), end: Offset(4, 4), duration: 500.ms); // Blur out (blurred to sharp) Widget blurOut = Image.asset('photo.jpg') .animate() .blur(begin: Offset(4, 4), end: Offset(0, 0), duration: 500.ms); // Horizontal blur only Widget horizontalBlur = Text("Horizontal") .animate() .blurX(begin: 0, end: 5, duration: 600.ms); // Vertical blur only Widget verticalBlur = Text("Vertical") .animate() .blurY(begin: 0, end: 5, duration: 600.ms); // Uniform blur Widget uniformBlur = Container( padding: EdgeInsets.all(20), child: Text("Uniform Blur"), ).animate() .blurXY(end: 3, duration: 500.ms); ``` -------------------------------- ### Animation with Default and Inherited Parameters in Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Demonstrates how animation effects inherit `duration` and `curve` parameters from previous effects or default values if not explicitly set. This allows for consistent animation styling. ```dart Text("Hello World!").animate() .fadeIn() // uses `Animate.defaultDuration` .scale() // inherits duration from fadeIn .move(delay: 300.ms, duration: 600.ms) // runs after the above w/new duration .blurXY() // inherits the delay & duration from move ``` -------------------------------- ### Tint Effect with Color Parameter in Dart Source: https://github.com/gskinner/flutter_animate/blob/main/README.md Shows how to apply a `tint` effect to a widget, specifying the target color. This effect modifies the color of the widget. ```dart Text('Hello').animate().tint(color: Colors.purple) ``` -------------------------------- ### Create shake effect animations in Flutter Source: https://context7.com/gskinner/flutter_animate/llms.txt Implements shake animations using rotational or translational movements. Supports horizontal, vertical, and combined shaking with customizable frequency, intensity, and easing. Requires flutter_animate package dependency. ```dart import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; // Default rotational shake Widget rotationalShake = Text("Shake") .animate() .shake(duration: 500.ms); // Horizontal shake Widget shakeHorizontal = Text("Error!") .animate() .shakeX(duration: 400.ms, hz: 5, amount: 10); // Vertical shake Widget shakeVertical = Icon(Icons.warning) .animate() .shakeY(duration: 400.ms, hz: 3, amount: 5); // Custom shake with both rotation and offset Widget customShake = Container( padding: EdgeInsets.all(16), child: Text("Custom Shake"), ).animate() .shake( duration: 600.ms, hz: 4, rotation: 0.05, offset: Offset(5, 0), ); ```