### Install Application Executable Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This makes the application runnable after installation. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installation Configuration Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Configures the installation process, setting the install prefix to a bundle directory and ensuring a clean build bundle on each run. It installs the executable, ICU data, Flutter library, and bundled plugin libraries. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. 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) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. 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) ``` -------------------------------- ### Define Installation Directories for Bundle Data and Libraries Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Sets the specific subdirectories within the installation prefix for bundle data (like assets) and libraries. This organizes the installed application structure. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install AOT Library for Release/Profile Builds Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, but only for 'Profile' and 'Release' configurations. This optimizes performance for production builds. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the bundle's library directory. This ensures that all necessary plugin code is available at runtime. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs the main Flutter library file to the bundle's library directory. This is a core component required for the Flutter application to run. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### AnimatedReorderableListView Example Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Example of using AnimatedReorderableListView for a to-do list with add, delete, and drag-and-drop reordering functionality. Requires items, itemBuilder, onReorder, and isSameItem. ```dart class TodoList extends StatefulWidget { const TodoList({super.key}); @override State createState() => _TodoListState(); } class _TodoListState extends State { List todos = [ Todo(id: 1, title: 'Buy groceries'), Todo(id: 2, title: 'Walk the dog'), Todo(id: 3, title: 'Read a book'), ]; void _addTodo() { setState(() { todos.insert(0, Todo(id: DateTime.now().millisecondsSinceEpoch, title: 'New task')); }); } void _removeTodo(int index) { setState(() => todos.removeAt(index)); } @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: FloatingActionButton( onPressed: _addTodo, child: const Icon(Icons.add), ), body: AnimatedReorderableListView( items: todos, // Every item widget must carry a unique Key itemBuilder: (context, index) => ListTile( key: ValueKey(todos[index].id), title: Text(todos[index].title), trailing: IconButton( icon: const Icon(Icons.delete), onPressed: () => _removeTodo(index), ), ), // Enter: fade + slide from top; Exit: slide up enterTransition: [FadeIn(), SlideInDown()], exitTransition: [SlideInUp()], insertDuration: const Duration(milliseconds: 350), removeDuration: const Duration(milliseconds: 300), // Fired when the user drops an item at a new position onReorder: (oldIndex, newIndex) { setState(() { final item = todos.removeAt(oldIndex); todos.insert(newIndex, item); }); }, onReorderStart: (index) => debugPrint('Drag started at $index'), onReorderEnd: (index) => debugPrint('Dropped at $index'), // Prevents spurious animations when the object reference changes isSameItem: (a, b) => a.id == b.id, dragStartDelay: const Duration(milliseconds: 400), padding: const EdgeInsets.all(8), ), ); } } ``` -------------------------------- ### Install Flutter Assets Directory Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring that all application assets (images, fonts, etc.) are copied to the correct location. It also removes stale assets before copying. ```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) ``` -------------------------------- ### Set Installation Directory for Build Bundle Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Defines the destination directory for the build bundle, ensuring support files are placed next to the executable for in-place execution. This is crucial for Visual Studio builds. ```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() ``` -------------------------------- ### Install ICU Data File Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Installs the ICU data file to the bundle's data directory. This file is necessary for internationalization and localization features. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Specifies the minimum required CMake version and the project name. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### AnimatedListView Example Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Employ AnimatedListView for dynamic lists where items are inserted or removed with animations, but reordering is not required. Configure custom enter and exit transitions. Ensure `isSameItem` is correctly implemented for accurate item identification during animations. ```dart class NotificationFeed extends StatefulWidget { const NotificationFeed({super.key}); @override State createState() => _NotificationFeedState(); } class _NotificationFeedState extends State { List notifications = []; void _addNotification(Notification n) => setState(() => notifications.insert(0, n)); void _dismiss(int index) => setState(() => notifications.removeAt(index)); @override Widget build(BuildContext context) { return AnimatedListView( items: notifications, itemBuilder: (context, index) { final n = notifications[index]; return Dismissible( key: ValueKey(n.id), onDismissed: (_) => _dismiss(index), child: ListTile( leading: const Icon(Icons.notifications), title: Text(n.message), ), ); }, enterTransition: [ FadeIn(duration: const Duration(milliseconds: 400)), SlideInRight(delay: const Duration(milliseconds: 100)), ], exitTransition: [ FadeIn(duration: const Duration(milliseconds: 200)), SlideInLeft(), ], isSameItem: (a, b) => a.id == b.id, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), ); } } ``` -------------------------------- ### Install AOT Library Conditionally in CMake Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Installs the AOT library to the runtime destination only when the build type is not Debug. Ensure the AOT_LIBRARY variable is defined. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### AnimatedReorderableGridView Example Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Use AnimatedReorderableGridView for grid layouts that require drag-and-drop functionality. Configure enter/exit transitions, durations, and item locking/non-draggable behavior. The proxyDecorator customizes the appearance of the item being dragged. ```dart class PhotoGrid extends StatefulWidget { const PhotoGrid({super.key}); @override State createState() => _PhotoGridState(); } class _PhotoGridState extends State { List photos = List.generate( 12, (i) => Photo(id: i, url: 'https://picsum.photos/seed/$i/200'), ); @override Widget build(BuildContext context) { return AnimatedReorderableGridView( items: photos, itemBuilder: (context, index) { final photo = photos[index]; return Card( key: ValueKey(photo.id), child: Image.network(photo.url, fit: BoxFit.cover), ); }, sliverGridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, mainAxisSpacing: 8, crossAxisSpacing: 8, ), enterTransition: [FlipInX(), ScaleIn()], exitTransition: [SlideInLeft()], insertDuration: const Duration(milliseconds: 300), removeDuration: const Duration(milliseconds: 300), onReorder: (oldIndex, newIndex) { setState(() { final item = photos.removeAt(oldIndex); photos.insert(newIndex, item); }); }, // Decorate the dragged proxy item with elevation proxyDecorator: (child, index, animation) { return AnimatedBuilder( animation: animation, builder: (context, child) { final elevation = lerpDouble(0, 8, Curves.easeInOut.transform(animation.value))!; return Material(elevation: elevation, color: Colors.transparent, child: child); }, child: child, ); }, isSameItem: (a, b) => a.id == b.id, dragStartDelay: const Duration(milliseconds: 300), // Item with id=0 cannot be dragged or repositioned lockedItems: photos.where((p) => p.id == 0).toList(), // Item with id=1 can be reordered but not dragged nonDraggableItems: photos.where((p) => p.id == 1).toList(), ); } } ``` -------------------------------- ### Find System Dependencies Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries like GTK, GLIB, and GIO, which are essential for Flutter's Linux desktop embedding. ```cmake 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) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Applies a predefined set of build settings to the application target. This can be removed if custom build settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and adds the source directory to include paths. Add any application-specific dependencies here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) ``` ```cmake target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") ``` ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Project Configuration Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Sets the minimum CMake version and project name. It also defines the application's binary name and GTK application ID. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. 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() # Define build configuration options. 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() ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support in the project. This is important for handling international characters correctly. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Create Flutter Wrapper Application Library Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Builds a STATIC library for the Flutter application wrapper, using core and application-specific C++ sources. It links against the Flutter library and sets include directories. ```cmake 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) ``` -------------------------------- ### Configure Flutter Tool Backend Custom Command Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend script. This command generates necessary build artifacts like the Flutter DLL and headers, using environment variables and configuration settings. ```cmake 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 ) ``` -------------------------------- ### Configure Flutter Interface Library Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Creates an INTERFACE library for Flutter, setting include directories and linking against the Flutter DLL. It also adds a dependency on the flutter_assemble target. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Includes Flutter's managed directory and checks for GTK+ 3.0 using PkgConfig. It also defines the APPLICATION_ID for the build. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Set Runtime Output Directory Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Configures the runtime output directory for the executable to a subdirectory. This ensures the executable is launched correctly with its resources. ```cmake # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Create Flutter Wrapper Plugin Library Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Builds a STATIC library for the Flutter plugin wrapper, incorporating core and plugin-specific C++ sources. It sets visibility to hidden and links against the Flutter library. ```cmake 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 Rules Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Includes the CMake rules for building generated plugins, which manage plugin compilation and integration into the application. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define C++ Wrapper Sources for Plugin Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Lists and prefixes C++ source files required for the Flutter plugin wrapper, including core and plugin-specific implementations. ```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}/") ``` -------------------------------- ### Define C++ Wrapper Sources for Application Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Lists and prefixes C++ source files for the Flutter application wrapper, including core and engine/view controller implementations. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Configures linker and compiler flags for the 'Profile' build mode, typically by inheriting settings from the 'Release' mode. This ensures consistent performance tuning for profiling. ```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}") ``` -------------------------------- ### Import animated_reorderable_list Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Import the main barrel file of the package into your Dart code. ```dart import 'package:animated_reorderable_list/animated_reorderable_list.dart'; ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt A function to apply common compilation settings to a target, including C++ standard, warning levels, and specific compiler options. Use with caution for plugins. ```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() ``` -------------------------------- ### Define Application Executable Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Defines the main executable target for the application, including all necessary source files. Standard build settings are applied to this target. ```cmake # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Dependencies and Build Rules Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Links the application executable with the Flutter library and GTK+. It also adds a dependency on the flutter_assemble target. ```cmake # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Assemble Flutter Assets Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom command and target to assemble Flutter assets, including the shared library and headers, by invoking the Flutter tool backend. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Set Executable Binary Name Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Defines the name of the executable file that will be created. This allows for easy customization of the application's on-disk name. ```cmake set(BINARY_NAME "example") ``` -------------------------------- ### Opt-in to Modern CMake Behaviors Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Explicitly enables modern CMake behaviors to avoid warnings with newer CMake versions. This ensures compatibility and adherence to current best practices. ```cmake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Include Runner Subdirectory Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Includes the 'runner' subdirectory, which likely contains the main application build logic. ```cmake add_subdirectory("runner") ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Sets preprocessor definitions to include Flutter version information in the build. This allows access to version details within the application code. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/CMakeLists.txt Defines a function to apply common compilation features and options to a target. It enables C++14, sets warning flags, and optimizes for non-Debug builds. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. 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() ``` -------------------------------- ### Flutter Web Entrypoint Initialization Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/web/index.html This JavaScript code is injected by the Flutter build process. It handles loading the main Dart entrypoint and initializing the Flutter engine for web applications. Ensure the serviceWorkerVersion is correctly set if you are using service workers. ```javascript var serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Define Executable Target Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Defines the main executable for the Windows runner. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` to function correctly. Add any new source files to this list. ```cmake 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" ) ``` -------------------------------- ### Configure Build Types for Multi-Config Generators Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) when using a multi-config generator. This ensures consistent build options across different configurations. ```cmake set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) ``` -------------------------------- ### AnimatedGridView for Product Catalogs Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Use AnimatedGridView for displaying items in a grid with animated insertions and removals. It's suitable for dynamic content like product catalogs or image galleries where items are updated programmatically. Ensure `isSameItem` is correctly implemented for efficient updates. ```dart class ProductCatalog extends StatefulWidget { const ProductCatalog({super.key}); @override State createState() => _ProductCatalogState(); } class _ProductCatalogState extends State { List products = fetchInitialProducts(); // returns List void _filterByCategory(String category) { setState(() { products = allProducts.where((p) => p.category == category).toList(); }); } @override Widget build(BuildContext context) { return AnimatedGridView( items: products, itemBuilder: (context, index) { final product = products[index]; return ProductCard( key: ValueKey(product.id), product: product, ); }, sliverGridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200, childAspectRatio: 0.75, mainAxisSpacing: 12, crossAxisSpacing: 12, ), enterTransition: [ScaleIn(), FadeIn()], exitTransition: [ScaleInBottom()], insertDuration: const Duration(milliseconds: 400), removeDuration: const Duration(milliseconds: 300), isSameItem: (a, b) => a.id == b.id, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), ); } } ``` -------------------------------- ### Include Flutter Managed Directory Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Adds the Flutter managed directory to the build. This is typically where Flutter's build system resides. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Custom Insert/Remove Builders for AnimatedListView Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Implement fully custom transition widgets for item insertion and removal by overriding `insertItemBuilder` and `removeItemBuilder`. These builders provide an `Animation` to control the child widget's transition, offering fine-grained control over entrance and exit effects. ```dart AnimatedListView( items: messages, itemBuilder: (context, index) => MessageBubble( key: ValueKey(messages[index].id), message: messages[index], ), isSameItem: (a, b) => a.id == b.id, // Custom scale+fade entrance insertItemBuilder: (Widget child, Animation animation) { return FadeTransition( opacity: animation, child: ScaleTransition( scale: CurvedAnimation(parent: animation, curve: Curves.elasticOut), child: child, ), ); }, // Custom slide-out exit removeItemBuilder: (Widget child, Animation animation) { return SlideTransition( position: Tween( begin: Offset.zero, end: const Offset(1.5, 0), ).animate(CurvedAnimation(parent: animation, curve: Curves.easeIn)), child: FadeTransition(opacity: animation, child: child), ); }, ) ``` -------------------------------- ### Enter and Exit Transitions for AnimatedGridView Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Apply custom enter and exit transitions for item animations. Defaults to FadeIn() if not specified. ```dart //optional enterTransition: [FadeIn(), ScaleIn()], exitTransition: [SlideIn()], ``` -------------------------------- ### Define Flutter Library Headers Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Appends necessary Flutter header files to a list, which are then prefixed with the ephemeral directory path. ```cmake 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}/") ``` -------------------------------- ### Include Generated Plugin Build Rules Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Includes the CMake file that manages the building of plugins and their integration into the application. This is essential for using external Flutter packages. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### AnimatedReorderableGridView Usage Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Implement a reorderable grid view with built-in drag-and-drop support. Configure item builders, grid delegates, enter/exit transitions, and reorder callbacks. ```dart AnimatedReorderableGridView( items: list, itemBuilder: (BuildContext context, int index) { final user = list[index]; return ItemCard( key: ValueKey(user.id), id: user.id, ); }, sliverGridDelegate: SliverReorderableGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4), enterTransition: [FlipInX(), ScaleIn()], exitTransition: [SlideInLeft()], insertDuration: const Duration(milliseconds: 300), removeDuration: const Duration(milliseconds: 300), onReorder: (int oldIndex, int newIndex) { setState(() { final User user = list.removeAt(oldIndex); list.insert(newIndex, user); }); }, dragStartDelay: const Duration(milliseconds: 300), isSameItem: (a, b) => a.id == b.id, ) ``` -------------------------------- ### Using ReorderableGridDragStartListener for Custom Drag Handles Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Use ReorderableGridDragStartListener when addDragStartListener is false on the parent to attach drag handles to specific sub-widgets. This allows only the drag handle icon to initiate a drag, while the rest of the tile remains tappable. ```dart AnimatedReorderableGridView( items: tiles, itemBuilder: (context, index) { return Stack( key: ValueKey(tiles[index].id), children: [ TileWidget(tile: tiles[index]), // Only the handle icon starts the drag; the rest of the tile is tappable Positioned( top: 4, right: 4, child: ReorderableGridDragStartListener( index: index, child: const Icon(Icons.drag_handle, color: Colors.white), ), ), ], ); }, sliverGridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), onReorder: (oldIndex, newIndex) { setState(() { tiles.insert(newIndex, tiles.removeAt(oldIndex)); }); }, isSameItem: (a, b) => a.id == b.id, // Disable automatic drag wrapping; rely solely on the listener above addDragStartListener: false, ) ``` -------------------------------- ### Add animated_reorderable_list to pubspec.yaml Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Add the package to your pubspec.yaml file to include it in your Flutter project. ```yaml # pubspec.yaml dependencies: animated_reorderable_list: ^1.3.0 ``` -------------------------------- ### Customizing Transitions in AnimatedReorderableListView Source: https://context7.com/canopas/animated_reorderable_list/llms.txt Configure parallel enter and exit animations for list items using `enterTransition` and `exitTransition`. Effects can be sequenced using `delay`, and each effect accepts `duration`, `delay`, and `curve`. The `insertDuration` property overrides individual effect durations for insertions. ```dart // Available AnimationEffect types: // FadeIn | FlipInX | FlipInY | Landing | SizeAnimation // ScaleIn | ScaleInTop | ScaleInBottom | ScaleInLeft | ScaleInRight // SlideInLeft | SlideInRight | SlideInUp | SlideInDown AnimatedReorderableListView( items: items, itemBuilder: (context, index) => ItemTile(key: ValueKey(items[index].id)), onReorder: (old, next) => setState(() { items.insert(next, items.removeAt(old)); }), isSameItem: (a, b) => a.id == b.id, // Run FadeIn and SlideInDown simultaneously on insert enterTransition: [ FadeIn( duration: const Duration(milliseconds: 500), curve: Curves.easeOut, ), SlideInDown( duration: const Duration(milliseconds: 500), delay: const Duration(milliseconds: 50), ), ], // Slide out to left with fade on removal exitTransition: [ SlideInLeft(duration: const Duration(milliseconds: 300)), FadeIn(duration: const Duration(milliseconds: 300)), ], // insertDuration overrides all per-effect durations in enterTransition insertDuration: const Duration(milliseconds: 400), ) ``` -------------------------------- ### Advanced Animation Parameters in AnimatedGridView Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Customize animation behavior with delay, duration, and curve. Animations run in parallel, but delay can create sequential execution. ```dart //optional enterTransition: [ FadeIn( duration: const Duration(milliseconds: 300), delay: const Duration(milliseconds: 100)), ScaleIn( duration: const Duration(milliseconds: 500), curve: Curves.bounceInOut) ], ``` -------------------------------- ### Configure Flutter Library Target Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library target for Flutter, setting include directories and linking against system libraries and the Flutter shared library. ```cmake 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 ) ``` -------------------------------- ### Custom Item Builders for AnimatedGridView Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Implement custom insertItemBuilder or removeItemBuilder for unique animations. These override the enterTransition and exitTransition respectively. ```dart //optional insertItemBuilder: (Widget child, Animation animation){ return ScaleTransition( scale: animation, child: child, ); } removeItemBuilder: (Widget child, Animation animation){ return ScaleTransition( scale: animation, child: child, ); } ``` -------------------------------- ### AnimatedReorderableListView Usage Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Implement a reorderable list view with drag-and-drop functionality. Customize item builders, transitions, durations, and reorder logic. ```dart AnimatedReorderableListView( items: list, itemBuilder: (BuildContext context, int index) { final user = list[index]; return ItemTile( key: ValueKey(user.id), id: user.id, ); }, enterTransition: [SlideInDown()], exitTransition: [SlideInUp()], insertDuration: const Duration(milliseconds: 300), removeDuration: const Duration(milliseconds: 300), dragStartDelay: const Duration(milliseconds: 300), onReorder: (int oldIndex, int newIndex) { setState(() { final User user = list.removeAt(oldIndex); list.insert(newIndex, user); }); }, isSameItem: (a, b) => a.id == b.id ) ``` -------------------------------- ### Basic AnimatedGridView Usage Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Use AnimatedGridView for animating item insertions and removals without drag-and-drop. Ensure to provide a unique key for each item. ```dart AnimatedGridView( items: list, itemBuilder: (context, index) { final user = list[index]; return ItemCard( key: ValueKey(user.id), id: user.id, ); }, sliverGridDelegate: SliverReorderableGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4), enterTransition: [FadeIn(), ScaleIn()], exitTransition: [SlideInDown()], isSameItem: (a, b) => a.id == b.id), ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This dependency is crucial and must not be removed. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Define List Prepend Function Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/linux/flutter/CMakeLists.txt A custom CMake function to prepend an element to a list, as the standard 'list(TRANSFORM ... PREPEND ...)' is not available in CMake 3.10. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Set Flutter Library and ICU Data Path Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Configures the path to the Flutter Windows DLL and the ICU data file, essential for Flutter's internationalization support. ```cmake 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) ``` -------------------------------- ### Animation Durations for AnimatedGridView Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Specify insert and remove durations for item animations. Defaults to 300 milliseconds if not provided. ```dart //optional insertDuration: const Duration(milliseconds: 300), removeDuration: const Duration(milliseconds:300), ``` -------------------------------- ### Set Default Build Type if Not Specified Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/CMakeLists.txt Sets the default build type to 'Debug' if it's not already defined. This is useful for single-configuration generators to ensure a default build mode. ```cmake set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") ``` -------------------------------- ### Define Flutter Assemble Custom Target Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/flutter/CMakeLists.txt Creates a custom target 'flutter_assemble' that depends on the generated Flutter library, headers, and wrapper source files. This target ensures these components are built before they are needed by other targets. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### AnimatedListView Usage Source: https://github.com/canopas/animated_reorderable_list/blob/main/README.md Use AnimatedListView for animating item insertions and removals without drag-and-drop functionality. Configure item builders and transitions. ```dart AnimatedListView( items: list, itemBuilder: (context, index) { final user = list[index]; return ItemTile( key: ValueKey(user.id), id: user.id, ); }, enterTransition: [FadeIn(), ScaleIn()] exitTransition: [SlideInUp()], isSameItem: (a, b) => a.id == b.id, ) ``` -------------------------------- ### Integrating ReorderableAnimatedListImpl within CustomScrollView Source: https://context7.com/canopas/animated_reorderable_list/llms.txt ReorderableAnimatedListImpl is a sliver-level widget that can be used inside a CustomScrollView with other slivers like SliverAppBar or SliverToBoxAdapter. It supports both vertical and grid layouts. ```dart CustomScrollView( slivers: [ const SliverAppBar( title: Text('My App'), floating: true, ), SliverToBoxAdapter( child: const Padding( padding: EdgeInsets.all(16), child: Text('Items', style: TextStyle(fontSize: 20)), ), ), // List variant ReorderableAnimatedListImpl( items: contacts, itemBuilder: (context, index) => ContactRow( key: ValueKey(contacts[index].id), contact: contacts[index], ), scrollDirection: Axis.vertical, enterTransition: [FadeIn(), SlideInDown()], exitTransition: [FadeIn()], onReorder: (old, next) { setState(() => contacts.insert(next, contacts.removeAt(old))); }, isSameItem: (a, b) => a.id == b.id, ), // Grid variant — use the named constructor ReorderableAnimatedListImpl.grid( items: photos, itemBuilder: (context, index) => PhotoCard( key: ValueKey(photos[index].id), ), sliverGridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), scrollDirection: Axis.vertical, enterTransition: [ScaleIn()], exitTransition: [ScaleIn()], onReorder: (old, next) { setState(() => photos.insert(next, photos.removeAt(old))); }, isSameItem: (a, b) => a.id == b.id, ), ], ) ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/canopas/animated_reorderable_list/blob/main/example/windows/runner/CMakeLists.txt Disables Windows-specific macros like NOMINMAX that can conflict with standard C++ library functions, preventing potential compilation errors. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.