### Basic Usage of InteractiveSlider Widget in Dart Source: https://github.com/jonas-zebari/interactive_slider/blob/main/README.md This Dart code provides a fundamental example of how to implement the 'InteractiveSlider' widget. It showcases setting start, center, and end icons, defining minimum and maximum values, and handling changes with the 'onChanged' callback. The example assumes a 'setState' context for updating the UI. ```dart InteractiveSlider( startIcon: const Icon(CupertinoIcons.volume_down), centerIcon: const Text('Center'), endIcon: const Icon(CupertinoIcons.volume_up), min: 1.0, max: 15.0, onChanged: (value) => setState(() => _value = value), ) ``` -------------------------------- ### CMake Installation Rules Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Configures the installation process for the application bundle. It defines installation directories and installs the executable, ICU data, Flutter library, bundled plugin libraries, and 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(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) ``` -------------------------------- ### CMake Installation Rules Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/CMakeLists.txt Configures the installation process for the application, including the executable, data files, libraries, and assets. Ensures runtime components are placed correctly for in-place execution. ```cmake # === Installation === 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) ``` -------------------------------- ### Install AOT Library Conditionally (CMake) Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt This CMake script installs the AOT library to the specified destination. The installation is gated by a condition that checks if the CMAKE_BUILD_TYPE does not match 'Debug'. This ensures the library is only installed on release or non-debug builds, reducing overhead in development environments. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### CMake Cross-building Setup Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Configures CMake for cross-building by setting the sysroot and search paths when a target platform sysroot is specified. This ensures correct library and header finding during cross-compilation. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Flutter: Customize Icon Positions in InteractiveSlider Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Demonstrates different icon positioning modes (inline, below, inside) for the InteractiveSlider widget using the `iconPosition` property. This example showcases how to configure the placement of start, center, and end icons. Requires Flutter SDK and the 'interactive_slider' package. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class IconPositionExample extends StatelessWidget { @override Widget build(BuildContext context) { return ListView( padding: const EdgeInsets.all(16), children: [ // Icons appear inline on the left and right of the slider const InteractiveSlider( iconPosition: IconPosition.inline, startIcon: Icon(CupertinoIcons.volume_down), endIcon: Icon(CupertinoIcons.volume_up), ), const SizedBox(height: 20), // Icons appear below the slider bar const InteractiveSlider( iconPosition: IconPosition.below, startIcon: Icon(CupertinoIcons.volume_down), centerIcon: Text('Center'), endIcon: Icon(CupertinoIcons.volume_up), ), const SizedBox(height: 20), // Icons appear inside the slider bar const InteractiveSlider( iconPosition: IconPosition.inside, startIcon: Icon(CupertinoIcons.volume_down), centerIcon: Text('Volume'), endIcon: Icon(CupertinoIcons.volume_up), unfocusedHeight: 40, focusedHeight: 50, iconGap: 16, ), ], ); } } ``` -------------------------------- ### Customize Slider Styling and Transitions (Dart) Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Provides an example of how to customize the appearance and animation of the Interactive Slider, including colors, margins, heights, and transition behaviors. This allows for fine-grained control over the slider's visual presentation. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class StyledSlider extends StatelessWidget { @override Widget build(BuildContext context) { return InteractiveSlider( // Layout and sizing padding: const EdgeInsets.all(20), unfocusedMargin: const EdgeInsets.symmetric(horizontal: 16), focusedMargin: EdgeInsets.zero, unfocusedHeight: 12.0, focusedHeight: 24.0, iconGap: 12.0, // Colors and appearance foregroundColor: Colors.deepPurple, backgroundColor: Colors.deepPurple.withOpacity(0.1), iconColor: Colors.deepPurple, brightness: Brightness.light, unfocusedOpacity: 0.6, // Transitions transitionDuration: const Duration(milliseconds: 500), transitionCurvePeriod: 1.5, // Icons startIcon: const Icon(CupertinoIcons.moon_stars), endIcon: const Icon(CupertinoIcons.sun_max), // Behavior min: 0.0, max: 100.0, initialProgress: 0.3, onChanged: (value) { print('Current: $value'); }, onFocused: (value) { print('User started dragging at: $value'); }, onProgressUpdated: (value) { print('User finished at: $value'); }, ); } } ``` -------------------------------- ### Dart: Apply Gradient Colors to InteractiveSlider Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Illustrates how to use gradient colors for the `InteractiveSlider`'s progress bar in Flutter. This example demonstrates applying `LinearGradient` and `RadialGradient` with different `GradientSize` options (`totalWidth` and `progressWidth`) to achieve various visual effects for the slider's track. ```dart import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class GradientSliderExample extends StatelessWidget { @override Widget build(BuildContext context) { return ListView( padding: const EdgeInsets.all(16), children: [ // Gradient spans the entire slider width const InteractiveSlider( unfocusedOpacity: 1.0, unfocusedHeight: 30, focusedHeight: 40, gradient: LinearGradient( colors: [Colors.blue, Colors.purple, Colors.pink], ), gradientSize: GradientSize.totalWidth, ), const SizedBox(height: 20), // Gradient only spans the progress portion const InteractiveSlider( unfocusedOpacity: 1.0, unfocusedHeight: 30, focusedHeight: 40, gradient: LinearGradient( colors: [Colors.green, Colors.yellow, Colors.red], ), gradientSize: GradientSize.progressWidth, ), const SizedBox(height: 20), // Radial gradient const InteractiveSlider( unfocusedOpacity: 1.0, unfocusedHeight: 30, focusedHeight: 40, gradient: RadialGradient( colors: [Colors.cyan, Colors.indigo], center: Alignment.centerLeft, ), ), ], ); } } ``` -------------------------------- ### Dart: Apply Custom Shape Borders to InteractiveSlider Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Shows how to apply different `ShapeBorder` types to the `InteractiveSlider` widget in Flutter to customize the appearance of its progress bar. Examples include `StadiumBorder`, `RoundedRectangleBorder`, `BeveledRectangleBorder`, and `ContinuousRectangleBorder`, each offering distinct corner and edge styles. ```dart import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class CustomShapesExample extends StatelessWidget { @override Widget build(BuildContext context) { return ListView( padding: const EdgeInsets.all(16), children: [ // Default stadium border (rounded ends) const InteractiveSlider( unfocusedHeight: 30, focusedHeight: 40, shapeBorder: StadiumBorder(), ), const SizedBox(height: 20), // Rounded rectangle border const InteractiveSlider( unfocusedHeight: 30, focusedHeight: 40, shapeBorder: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(8)), ), ), const SizedBox(height: 20), // Beveled rectangle border const InteractiveSlider( unfocusedHeight: 30, focusedHeight: 40, shapeBorder: BeveledRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(8)), ), ), const SizedBox(height: 20), // Continuous rectangle with border InteractiveSlider( unfocusedHeight: 30, focusedHeight: 40, shapeBorder: ContinuousRectangleBorder( borderRadius: BorderRadius.circular(20), ), ), ], ); } } ``` -------------------------------- ### Apply Standard Build Settings with CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Applies a predefined set of standard build settings to the application target. This simplifies configuration for common build requirements and can be modified or removed if custom build settings are needed. It uses the `apply_standard_settings` CMake macro. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### CMake Standard Compilation Settings Function Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/CMakeLists.txt Defines a reusable function `APPLY_STANDARD_SETTINGS` to apply common compilation features, options, and definitions to CMake targets. Ensures C++17 standard and specific warning levels. ```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 Project Configuration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/CMakeLists.txt Sets the minimum CMake version, project name, and executable name. It also explicitly opts into modern CMake behaviors for compatibility. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### CMake Executable Target Definition Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Defines the main executable target for the application, including source files like main.cc, my_application.cc, and generated plugin registrant. It applies standard build settings and links necessary libraries. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Runtime Output Directory Configuration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory within the build directory. This is done to ensure correct resource loading when the application is bundled. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Create Animated Icons with Slider Progress (Dart) Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Demonstrates how to use builder functions to create animated icons that dynamically respond to the slider's progress. This allows for visual feedback based on the slider's current value. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class AnimatedIconSlider extends StatelessWidget { @override Widget build(BuildContext context) { return InteractiveSlider( unfocusedHeight: 30, focusedHeight: 40, startIconBuilder: (context, progress, child) { return Transform.scale( scale: 1.0 - (progress * 0.3), child: Opacity( opacity: 1.0 - (progress * 0.5), child: const Icon(CupertinoIcons.volume_down), ), ); }, centerIconBuilder: (context, progress, child) { return Text( '${(progress * 100).toInt()}%', style: TextStyle( fontSize: 14 + (progress * 6), fontWeight: FontWeight.bold, ), ); }, endIconBuilder: (context, progress, child) { return Transform.scale( scale: 0.7 + (progress * 0.3), child: Opacity( opacity: 0.5 + (progress * 0.5), child: const Icon(CupertinoIcons.volume_up), ), ); }, ); } } ``` -------------------------------- ### Flutter: Implement Volume Control with InteractiveSlider Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Demonstrates how to use the InteractiveSlider widget to create a volume control. It showcases setting min/max values, initial progress, and handling value changes via `onChanged` and `onProgressUpdated` callbacks. Requires Flutter SDK and the 'interactive_slider' package. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class VolumeControl extends StatefulWidget { @override State createState() => _VolumeControlState(); } class _VolumeControlState extends State { double _volume = 7.5; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Volume: ${_volume.toStringAsFixed(1)}'), InteractiveSlider( startIcon: const Icon(CupertinoIcons.volume_down), endIcon: const Icon(CupertinoIcons.volume_up), min: 0.0, max: 15.0, initialProgress: 0.5, onChanged: (value) { setState(() => _volume = value); }, onProgressUpdated: (value) { print('Final volume: $value'); }, ), ], ), ), ); } } ``` -------------------------------- ### CMake Flutter and Runner Integration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/CMakeLists.txt Includes Flutter-specific build rules from the 'flutter' directory and integrates the application's runner build system defined in 'runner/CMakeLists.txt'. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Integrate Flutter Tool Backend with CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/flutter/CMakeLists.txt This CMake configuration defines a custom command to execute the Flutter tool backend script. It's designed to run every time due to a non-existent output file (`_phony_`), ensuring the Flutter library and headers are generated or updated based on the Flutter tool's output for the specified platform and build type. ```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. 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} ) ``` -------------------------------- ### Link Dependencies and Include Directories in CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Specifies the libraries and include directories required for the application build. It links against Flutter's core libraries (`flutter`, `flutter_wrapper_app`) and Windows-specific libraries (`dwmapi.lib`), while also setting the source directory as an include path. This ensures all necessary components are available during compilation and linking. ```cmake # 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}") ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, and executable binary name. It also defines the application's unique GTK identifier. ```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 Standard Settings Function Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Defines a function to apply standard compilation settings like C++ standard, warning levels, optimization, and NDEBUG definition to a given target. ```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 Application Target with CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Defines the main executable target for the application using CMake. It lists all source files, resource files, and generated files required for the build. Any new source files should be added to this list. The target name is linked to the BINARY_NAME variable for consistency with Flutter tooling. ```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" ) ``` -------------------------------- ### CMake Flutter and GTK Integration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Integrates Flutter's managed directory and finds PkgConfig to check for GTK 3.0 system dependencies. It also defines the application ID as a preprocessor macro. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### CMake Build Configuration Modes Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/CMakeLists.txt Configures build types (Debug, Profile, Release) based on whether the generator supports multi-configuration builds. Sets default build type if not specified. ```cmake 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}") ``` -------------------------------- ### CMake Plugin Registrant Inclusion Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Includes the CMake script responsible for building and registering Flutter plugins with the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Configure Flutter Library and Wrapper - CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/flutter/CMakeLists.txt This snippet configures the Flutter library and its C++ wrapper. It sets include directories, links libraries, and defines static libraries for both plugins and the application. It relies on generated CMake files and source files located in ephemeral and wrapper directories. ```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) # === Wrapper === 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) # 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) ``` -------------------------------- ### Configure Flutter Linux GTK Build with CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/flutter/CMakeLists.txt This CMake script configures the build for a Flutter Linux GTK application. It finds necessary system packages (GTK, GLIB, GIO), defines paths to Flutter libraries and headers, and sets up build targets for the Flutter library and assembly process. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # === Flutter Library === # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Add interactive_slider Dependency to pubspec.yaml Source: https://github.com/jonas-zebari/interactive_slider/blob/main/README.md This YAML snippet shows how to add the 'interactive_slider' package as a dependency in your project's 'pubspec.yaml' file. Ensure you use a compatible version. ```yaml dependencies: interactive_slider: ^0.5.0 ``` -------------------------------- ### Flutter Tool Backend Command - CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/flutter/CMakeLists.txt This snippet defines a custom command to invoke the Flutter tool backend. It's designed to run every time due to a phony target, ensuring build artifacts like the Flutter library and wrapper sources are generated. The command uses environment variables to configure the Flutter tool. ```cmake # === Flutter tool backend === # _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 ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Set Preprocessor Definitions for Build Version in CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Configures preprocessor definitions to embed Flutter version information directly into the compiled application. This allows the application to access version details like major, minor, patch, and build numbers at runtime. It uses `target_compile_definitions` to define these symbols. ```cmake # 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}") ``` -------------------------------- ### Flutter: Programmatically Control Slider with InteractiveSliderController Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Illustrates programmatic control of the InteractiveSlider using InteractiveSliderController. It shows how to initialize the controller, dispose of it, and manipulate the slider's value externally using buttons. Requires Flutter SDK and the 'interactive_slider' package. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class ControlledSlider extends StatefulWidget { @override State createState() => _ControlledSliderState(); } class _ControlledSliderState extends State { final _controller = InteractiveSliderController(0.5); @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ElevatedButton( onPressed: () => _controller.value = 0.0, child: const Text('Min'), ), ValueListenableBuilder( valueListenable: _controller, builder: (context, progress, child) { return Text('Progress: ${progress.toStringAsFixed(2)}'); }, ), ElevatedButton( onPressed: () => _controller.value = 1.0, child: const Text('Max'), ), ], ), InteractiveSlider( controller: _controller, startIcon: const Icon(CupertinoIcons.minus_circle), endIcon: const Icon(CupertinoIcons.add_circled), ), ], ); } } ``` -------------------------------- ### Import InteractiveSlider Widget in Dart Source: https://github.com/jonas-zebari/interactive_slider/blob/main/README.md This Dart code demonstrates how to import the 'InteractiveSlider' widget from the 'interactive_slider' package into your project. This import statement is necessary before you can use the widget in your UI. ```dart import 'package:interactive_slider/interactive_slider.dart'; ``` -------------------------------- ### Define Custom List Prepend Function in CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/flutter/CMakeLists.txt This CMake function emulates `list(TRANSFORM ... PREPEND ...)` for older CMake versions (pre-3.10). It iterates through a list and prepends a specified prefix to each element, modifying the original list in the parent scope. ```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 Build Type Configuration Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined, ensuring consistent build modes. It also enforces allowed build type strings. ```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() ``` -------------------------------- ### Add Flutter Build Asset Dependency in CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's asset assembly process (`flutter_assemble`) is completed before the application target is built. This is a critical step to guarantee that all necessary Flutter assets are generated and available for the application. It uses the `add_dependencies` CMake command. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Dart: Create Segmented Slider with InteractiveSlider Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Demonstrates how to create a discrete segmented slider using the `InteractiveSlider` widget in Flutter. It allows customization of the number of segments, min/max values, initial progress, and visual properties like height and divider color. The `onChanged` callback updates the slider's value, and `onProgressUpdated` logs the final progress. ```dart import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class RatingSlider extends StatefulWidget { @override State createState() => _RatingSliderState(); } class _RatingSliderState extends State { double _rating = 5.0; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Rating: ${_rating.toInt()}/10', style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const SizedBox(height: 20), InteractiveSlider( numberOfSegments: 10, min: 1.0, max: 10.0, initialProgress: 0.5, unfocusedHeight: 30, focusedHeight: 40, segmentDividerColor: Colors.grey.shade700, segmentDividerWidth: 2.0, foregroundColor: Colors.amber, onChanged: (value) { setState(() => _rating = value); }, onProgressUpdated: (value) { print('Final rating: ${value.toInt()}'); }, ), ], ); } } ``` -------------------------------- ### Manage Slider Interactivity and Disabled State (Dart) Source: https://context7.com/jonas-zebari/interactive_slider/llms.txt Illustrates how to control the enabled state of the Interactive Slider and its visual appearance when disabled. A SwitchListTile is used to toggle the slider's interactivity, demonstrating the `enabled` property and `disabledOpacity`. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:interactive_slider/interactive_slider.dart'; class DisabledSliderExample extends StatefulWidget { @override State createState() => _DisabledSliderExampleState(); } class _DisabledSliderExampleState extends State { bool _isEnabled = true; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SwitchListTile( title: const Text('Enable Slider'), value: _isEnabled, onChanged: (value) { setState(() => _isEnabled = value); }, ), const SizedBox(height: 20), InteractiveSlider( enabled: _isEnabled, disabledOpacity: 0.3, startIcon: const Icon(CupertinoIcons.volume_down), endIcon: const Icon(CupertinoIcons.volume_up), unfocusedHeight: 20, focusedHeight: 30, onChanged: (value) { print('Volume changed: $value'); }, ), ], ); } } ``` -------------------------------- ### Disable Colliding Windows Macros in CMake Source: https://github.com/jonas-zebari/interactive_slider/blob/main/example/windows/runner/CMakeLists.txt Disables specific Windows macros (`NOMINMAX`) that can conflict with C++ standard library functions, particularly `min` and `max`. This prevents potential compilation errors and ensures standard C++ behavior. The definition is applied privately to the target. ```cmake # Disable Windows macros that collide with C++ standard library functions. 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.