### CMake Installation Rules Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt Configures the installation process, creating a relocatable application bundle. It installs the executable, ICU data, Flutter library, bundled plugins, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake: Set Flutter Library and Headers Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/flutter/CMakeLists.txt This snippet configures CMake to define the Flutter library path and its associated header files. It uses variables like `EPHEMERAL_DIR` to locate these files and makes them available in the parent scope for installation steps. It also sets the project build directory and AOT library path. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # === 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) ``` -------------------------------- ### CMake: Custom Command for Flutter Tool Backend Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/flutter/CMakeLists.txt This CMake snippet defines a custom command to invoke the Flutter tool backend. It uses a phony output file to ensure the command runs on every build. The command is configured to run with specific environment variables and arguments, including the target platform and build configuration, to generate necessary Flutter build artifacts. ```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" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### CMake: Configure C++ Wrapper for Plugins Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/flutter/CMakeLists.txt This CMake configuration defines a static library for the Flutter C++ wrapper, specifically for use in plugins. It includes core implementation sources and plugin-specific sources, applies standard settings, and ensures position-independent code. It links against the main Flutter library and sets the include directory for the wrapper. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Wrapper sources needed for a plugin. 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}/") 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) ``` -------------------------------- ### Basic Custom Carousel Implementation Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/README.md A fundamental example demonstrating how to use the CustomCarousel widget. It takes a list of children and defines an `effectsBuilder` to control the visual presentation of each child based on its scroll position. The scrollRatio determines the offset. ```dart CustomCarousel( children: [card1, card2, etc], effectsBuilder: (index, scrollRatio, child) => Transform.translate( offset: Offset(0, scrollRatio * 250) , child: child ), ) ``` -------------------------------- ### CMake: Configure C++ Wrapper for Application Runner Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/flutter/CMakeLists.txt This CMake configuration defines a static library for the Flutter C++ wrapper, intended for the application runner. It includes core implementation sources and application-specific sources. It links against the main Flutter library and sets the include directory for the wrapper, enabling the application to interface with the Flutter engine. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Wrapper sources needed for the runner. 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_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 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 Assets Directory for Installation Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt This CMake code snippet defines the name for the Flutter asset directory and installs it to the application's data directory. It also removes any pre-existing asset directories to ensure a clean installation. This is crucial for deploying Flutter applications with custom assets. ```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 for Non-Debug Builds Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt This CMake code installs the Ahead-Of-Time (AOT) compiled library. It is conditionally executed only when the build type is not 'Debug', ensuring that performance-critical libraries are included in release builds while keeping debug builds lighter. The library is placed in the bundle's library directory. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Flutter Basic Carousel with Transform Effects Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Demonstrates creating a simple vertical carousel with custom transform, scale, and opacity effects based on the scroll ratio. This example utilizes the `CustomCarousel` widget and its `effectsBuilder` callback. It requires the `flutter_custom_carousel` package. ```dart import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; class SimpleCarouselExample extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomCarousel( children: List.generate( 10, (index) => Container( width: 200, height: 200, decoration: BoxDecoration( color: Colors.primaries[index % Colors.primaries.length], borderRadius: BorderRadius.circular(16), ), child: Center( child: Text( 'Item $index', style: TextStyle(fontSize: 24, color: Colors.white), ), ), ), ), effectsBuilder: (index, scrollRatio, child) { // scrollRatio ranges from -1 to +1, where 0 is centered return Transform.translate( offset: Offset(0, scrollRatio * 250), child: Transform.scale( scale: 1 - (scrollRatio.abs() * 0.3), child: Opacity( opacity: 1 - (scrollRatio.abs() * 0.5), child: child, ), ), ); }, ), ); } } ``` -------------------------------- ### Flutter Carousel with Flutter Animate Effects Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Integrates flutter_custom_carousel with flutter_animate to create dynamic visual effects for carousel items. This example shows how to apply fading, scaling, blurring, sliding, and rotating animations based on the item's scroll ratio. It requires the flutter and flutter_animate packages. ```dart import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; import 'package:flutter_animate/flutter_animate.dart'; class AnimateCarouselExample extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomCarousel( scrollDirection: Axis.horizontal, scrollSpeed: 0.5, alignment: Alignment.center, effectsBuilder: CustomCarousel.effectsBuilderFromAnimate( // Duration maps the scroll ratio: 0ms = -1, 100ms = 0, 200ms = +1 effects: EffectList() // Fade and scale items as they approach center (0-100ms) .fadeIn(duration: 100.ms, begin: 0.3) .scale(duration: 100.ms, begin: Offset(0.7, 0.7)) // Apply blur and movement as they leave (100-200ms) .blur(delay: 100.ms, duration: 100.ms, end: Offset(8, 8)) .slideX(delay: 100.ms, duration: 100.ms, end: 1.2) // Rotate slightly throughout the entire range .rotate(duration: 200.ms, begin: -0.05, end: 0.05), ), children: List.generate( 12, (i) => Container( width: 180, height: 240, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Colors.primaries[i % Colors.primaries.length], Colors.primaries[(i + 1) % Colors.primaries.length], ], ), borderRadius: BorderRadius.circular(20), ), child: Center( child: Text( 'Card $i', style: TextStyle(fontSize: 28, color: Colors.white), ), ), ), ), ), ); } } ``` -------------------------------- ### Flutter Carousel with Custom Scroll Physics Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Configures custom scroll physics for the flutter_custom_carousel widget to achieve specific snap behaviors and visual effects. This example utilizes `CustomCarouselScrollPhysics` for sticky scrolling and defines a custom `effectsBuilder` to create a card deck illusion. It requires the flutter package. ```dart import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; class PhysicsCarouselExample extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomCarousel( // Sticky physics: only advance one item at a time when "throwing" physics: CustomCarouselScrollPhysics( sticky: true, stiffness: 2.0, // Snappier settling (default: 1.0) ), scrollDirection: Axis.horizontal, scrollSpeed: 0.75, loop: true, tapToSelect: false, // Disable tap-to-select itemCountBefore: 3, itemCountAfter: 0, depthOrder: DepthOrder.reverse, // Earlier items drawn in front effectsBuilder: (index, scrollRatio, child) { // Create a card deck effect double offset = scrollRatio * 40; double scale = 1 - (scrollRatio.abs() * 0.1); return Transform.translate( offset: Offset(offset, scrollRatio.abs() * 20), child: Transform.scale( scale: scale, child: Opacity( opacity: scrollRatio > 0 ? 0 : (1 - scrollRatio.abs() * 0.4), child: child, ), ), ); }, children: List.generate( 20, (i) => Container( width: 280, height: 400, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(24), boxShadow: [ BoxShadow( color: Colors.black26, blurRadius: 16, offset: Offset(0, 8), ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(24), child: Image.network( 'https://picsum.photos/280/400?random=$i', fit: BoxFit.cover, errorBuilder: (_, __, ___) => Center( child: Icon(Icons.image, size: 64), ), ), ), ), ), ), ); } } ``` -------------------------------- ### CMake: Find and check PkgConfig modules for GTK, GLIB, GIO Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/flutter/CMakeLists.txt Uses `PkgConfig` to find and check for the presence of GTK, GLIB, and GIO libraries, which are essential system-level dependencies for the Flutter Linux GTK integration. It ensures that these packages are available and imported as targets for linking. ```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) ``` -------------------------------- ### CMake Project and Build Configuration Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/CMakeLists.txt Initializes the CMake project, sets the executable name, and defines build configuration types (Debug, Profile, Release). It also handles multi-configuration generators and sets default build types if not specified. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(VERSION 3.14...3.25) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt Sets up the minimum CMake version, project name, and executable binary name. It also defines the application ID, which is crucial for GTK applications. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### CMake Executable and Dependency Linking Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt Defines the main executable target, includes generated Flutter plugin registration, links necessary libraries (Flutter, GTK), and adds build dependencies. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Function for Standard Build Settings Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, options, and definitions to a target. This promotes code consistency across different parts of the build. ```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() ``` -------------------------------- ### CMake: Custom command for Flutter tool backend Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake command to run the Flutter tool backend script. This command is triggered to generate the Flutter library (`libflutter_linux_gtk.so`) and its associated headers. A dummy output file `_phony_` is used to ensure the command runs on every build, as direct input/output detection for the Flutter tool is not straightforward. ```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} ) ``` -------------------------------- ### Configure CMake Project for Flutter Runner Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/runner/CMakeLists.txt This CMake script sets up the build environment for a Flutter application runner. It specifies the minimum CMake version required, defines the project name, and adds the executable target. The script also includes build settings, preprocessor definitions for versioning, and links necessary libraries and include directories. It concludes by adding dependencies for Flutter tools. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, 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} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"" ) target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Flutter and Runner Integration Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner's CMakeLists.txt file. It also includes generated plugin build rules, essential for integrating Flutter plugins into the application. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### CMake: Define custom list prepend function Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/flutter/CMakeLists.txt Defines a CMake function `list_prepend` that prepends a given prefix to each element of a list. This is a workaround for older CMake versions (prior to 3.10) that do not support `list(TRANSFORM ... PREPEND ...)`. It iterates through the list and builds a new list with the prefix added to each item. ```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() ``` -------------------------------- ### CMake: Configure Flutter library and headers Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/flutter/CMakeLists.txt Sets up the Flutter library path, ICU data file, project build directory, and AOT library path. It also defines a list of Flutter library headers and configures an interface library target named 'flutter' to include these headers and link against the Flutter library and required system packages (GTK, GLIB, GIO). ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### CMake Build Type and Compilation Settings Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/example/linux/CMakeLists.txt Configures the build type (Debug, Profile, Release) and applies standard compilation features and options. It includes optimizations for non-Debug builds and NDEBUG definition. ```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() 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() ``` -------------------------------- ### Responsive Carousel with Mouse Drag - Dart Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Implements a responsive carousel widget in Flutter that supports mouse drag for desktop users. It configures the CustomCarousel to accept pointer device kinds including touch and mouse, and applies custom scroll physics and effects for a smooth user experience. Dependencies include flutter/gestures, flutter/material, and flutter_custom_carousel. ```dart import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; class ResponsiveCarouselExample extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomCarousel( scrollDirection: Axis.vertical, reverse: false, loop: false, // Enable mouse drag scrolling on desktop scrollBehavior: ScrollConfiguration.of(context).copyWith( dragDevices: { PointerDeviceKind.touch, PointerDeviceKind.mouse, }, scrollbars: false, ), // Use default bouncing physics instead of snapping physics: BouncingScrollPhysics(), tapToSelect: true, addRepaintBoundaries: true, addSemanticIndexes: true, itemCountBefore: 1, itemCountAfter: 1, effectsBuilder: (index, scrollRatio, child) { final offset = scrollRatio * 300; final scale = 1 - (scrollRatio.abs() * 0.2); return Transform.translate( offset: Offset(0, offset), child: Transform.scale( scale: scale, child: Opacity( opacity: (1 - scrollRatio.abs() * 0.6).clamp(0.4, 1.0), child: child, ), ), ); }, children: List.generate( 15, (i) => Padding( padding: EdgeInsets.symmetric(horizontal: 32, vertical: 16), child: Card( elevation: 8, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), child: Container( padding: EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Section ${i + 1}', style: Theme.of(context).textTheme.headlineMedium, ), SizedBox(height: 8), Text( 'This is content for section ${i + 1}. ' 'You can scroll using touch, mouse wheel, or mouse drag.', style: Theme.of(context).textTheme.bodyLarge, ), SizedBox(height: 16), LinearProgressIndicator( value: (i + 1) / 15, ), ], ), ), ), ), ), ), ); } } ``` -------------------------------- ### Horizontal Carousel with Programmatic Navigation and Callbacks Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Implements a controllable horizontal carousel using `CustomCarousel` and `CustomCarouselScrollController`. It handles `onSelectedItemChanged` and `onSettledItemChanged` events, and provides buttons for programmatic navigation like moving to the previous/next item, animating to a specific item, and jumping to an item. Dependencies include `flutter/material.dart` and `flutter_custom_carousel/flutter_custom_carousel.dart`. ```dart import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; class ControlledCarouselExample extends StatefulWidget { @override State createState() => _ControlledCarouselExampleState(); } class _ControlledCarouselExampleState extends State { late CustomCarouselScrollController _controller; int _selectedIndex = 0; int? _settledIndex; @override void initState() { super.initState(); _controller = CustomCarouselScrollController(initialItem: 2); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Expanded( child: CustomCarousel( scrollDirection: Axis.horizontal, controller: _controller, loop: true, tapToSelect: true, itemCountBefore: 2, itemCountAfter: 2, alignment: Alignment.center, onSelectedItemChanged: (index) { setState(() => _selectedIndex = index); print('Selected item: $index'); }, onSettledItemChanged: (index) { setState(() => _settledIndex = index); print('Settled on item: $index'); }, effectsBuilder: (index, scrollRatio, child) { return Transform.translate( offset: Offset(scrollRatio * 150, 0), child: child, ); }, children: List.generate( 8, (i) => Container( width: 150, height: 200, decoration: BoxDecoration( color: i == _selectedIndex ? Colors.blue : Colors.grey, borderRadius: BorderRadius.circular(12), border: Border.all( width: i == _settledIndex ? 4 : 2, color: Colors.black, ), ), child: Center(child: Text('$i')), ), ), ), ), Padding( padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ElevatedButton( onPressed: () => _controller.previousItem(), child: Text('Previous'), ), ElevatedButton( onPressed: () => _controller.nextItem( duration: Duration(milliseconds: 500), curve: Curves.easeInOut, ), child: Text('Next'), ), ElevatedButton( onPressed: () => _controller.animateToItem(0), child: Text('Go to First'), ), ElevatedButton( onPressed: () => _controller.jumpToItem(5), child: Text('Jump to 5'), ), ], ), ), ], ), ); } } ``` -------------------------------- ### Flutter Dart: Circular Carousel with 3D Perspective Source: https://context7.com/gskinnerteam/flutter_custom_carousel/llms.txt Implements a circular carousel with perspective transforms using the flutter_custom_carousel package. It customizes item positioning, rotation, scaling, and opacity based on scroll ratio to create a 3D effect. Dependencies include dart:math and flutter/material. ```dart import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:flutter_custom_carousel/flutter_custom_carousel.dart'; class CircularCarouselExample extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomCarousel( scrollDirection: Axis.horizontal, loop: true, alignment: Alignment.center, itemCountBefore: 3, itemCountAfter: 3, depthOrder: DepthOrder.selectedInFront, scrollSpeed: 0.4, effectsBuilder: (index, scrollRatio, child) { // Create circular arrangement final angle = scrollRatio * math.pi / 3; // 60 degrees per item final radius = 200.0; final x = math.sin(angle) * radius; final z = math.cos(angle) * radius - radius; final scale = 0.8 + (1 - scrollRatio.abs()) * 0.2; return Transform( alignment: Alignment.center, transform: Matrix4.identity() ..setEntry(3, 2, 0.001) // perspective ..translate(x, 0.0, z) ..rotateY(-angle * 0.5) ..scale(scale), child: Opacity( opacity: 1 - (scrollRatio.abs() * 0.3).clamp(0, 0.7), child: child, ), ); }, children: List.generate( 10, (i) => Container( width: 160, height: 220, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color.lerp( Colors.blue, Colors.purple, i / 10, )!, Color.lerp( Colors.purple, Colors.pink, i / 10, )!, ], ), borderRadius: BorderRadius.circular(16), boxShadow: [ BoxShadow( color: Colors.black38, blurRadius: 12, spreadRadius: 2, ), ], ), child: Center( child: Text( '${i + 1}', style: TextStyle( fontSize: 48, fontWeight: FontWeight.bold, color: Colors.white, ), ), ), ), ), ), ); } } ``` -------------------------------- ### Custom Carousel with Flutter Animate Source: https://github.com/gskinnerteam/flutter_custom_carousel/blob/main/README.md This snippet shows how to integrate the CustomCarousel widget with the Flutter Animate package. It utilizes `CustomCarousel.effectsBuilderFromAnimate` to apply predefined animations, such as vertical movement, to the carousel items. ```dart CustomCarousel( children: [card1, card2, etc], effectsBuilder: CustomCarousel.effectsBuilderFromAnimate( effects: EffectList().moveY(begin: -250, end: 250), ), ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.