### CMake Installation Rules for Windows Executable Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/CMakeLists.txt Configures the installation process for the Windows build, including setting the installation prefix to the executable's directory. It installs the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Rules Source: https://github.com/sunarya-thito/flexbox/blob/master/example/windows/CMakeLists.txt Sets up installation rules to copy support files next to the executable for in-place running, especially in Visual Studio. It installs the binary, ICU data, Flutter library, plugins, native assets, and assets directory, with special handling for AOT library in non-debug builds. This enables running the app from the build directory without bundling, but is specific to Windows and requires build outputs to be generated first. ```CMake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. 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() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # 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) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Dart Example: FlexItem Sizing with Extensions Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Compares the usage of FlexItem width and height properties with and without the flexiblebox package's extension methods. The example highlights how extensions like '.size' simplify the syntax for defining fixed dimensions. ```dart // Without extensions FlexItem( width: SizeUnit.fixed(100.0), height: SizeUnit.fixed(50.0), child: MyWidget(), ) // With extensions FlexItem( width: 100.size, height: 50.size, child: MyWidget(), ) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and executable name. It also configures build types (Debug, Profile, Release) and compiler flags for different configurations, including Unicode support and standard compilation settings. ```cmake cmake_minimum_required(VERSION 3.14) project(demo LANGUAGES CXX) set(BINARY_NAME "demo") 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 installation rules for Flutter Linux bundle Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/CMakeLists.txt Defines the bundle directory, ensures a clean install destination, and installs the executable, ICU data, Flutter library, plugin libraries, native assets, and Flutter assets. Includes conditional installation of the AOT library for non‑debug builds. ```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() 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) 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) if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Configure Flutter CMake Build System for Windows Source: https://github.com/sunarya-thito/flexbox/blob/master/example/windows/flutter/CMakeLists.txt Complete CMake configuration for Flutter Windows projects including library setup, wrapper configuration, and build target definitions. Sets up paths for Flutter DLL, ICU data, and C++ wrapper components with proper dependency management for plugin and app-specific builds. ```cmake # This file controls Flutter-level build steps. It should not be edited. 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") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === 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) # === 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" ${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} ) ``` -------------------------------- ### Install FlexibleBox Package Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Command to add the flexiblebox package to your Flutter project dependencies. ```bash flutter pub add flexiblebox ``` -------------------------------- ### Create Basic Row Flex Layout Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Example of creating a simple row-based flex layout using FlexBox and FlexItem widgets. Demonstrates flexible and fixed-width item configuration. ```dart FlexBox( direction: FlexDirection.row, rowGap: 8.0.spacing, children: [ FlexItem( flexGrow: 1.0, child: Container( color: Colors.red, height: 100, child: Center(child: Text('Flexible Item')), ), ), FlexItem( width: 100.0.size, child: Container( color: Colors.blue, height: 100, child: Center(child: Text('Fixed Width')), ), ), ], ) ``` -------------------------------- ### Configure FlexItem Properties Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Example showing how to configure individual FlexItem widgets within a FlexBox. Covers properties like flex grow/shrink, width, height, and self-alignment. ```dart FlexItem( flexGrow: 1.0, // Growth factor flexShrink: 0.0, // Shrink factor width: 200.0.size, // Preferred width height: 100.0.size, // Preferred height alignSelf: BoxAlignmentGeometry.start, // Individual alignment child: Container( color: Colors.blue, child: Center(child: Text('Flex Item')), ), ) ``` -------------------------------- ### Set Flutter Library and Build Paths Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Defines paths to the Flutter engine library, ICU data file, project build directory, and AOT library. These variables are set in parent scope for use during the install step. ```cmake 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) ``` -------------------------------- ### Flutter: RowBox and ColumnBox Convenience Widgets Source: https://context7.com/sunarya-thito/flexbox/llms.txt Demonstrates the usage of RowBox and ColumnBox, which are simplified widgets for common horizontal and vertical flex layouts, respectively. Examples include standard and reverse direction layouts with various alignment and spacing properties. ```dart // Horizontal layout (equivalent to FlexBox with direction: row) RowBox( alignItems: BoxAlignmentGeometry.center, justifyContent: BoxAlignmentBase.spaceBetween, rowGap: 16.spacing, children: [ FlexItem(child: Icon(Icons.home)), FlexItem(flexGrow: 1, child: Text('Home')), FlexItem(child: Icon(Icons.arrow_forward)), ], ) // Vertical layout (equivalent to FlexBox with direction: column) ColumnBox( alignItems: BoxAlignmentGeometry.stretch, columnGap: 8.spacing, padding: EdgeSpacing.symmetric(vertical: 12.spacing, horizontal: 16.spacing), children: [ FlexItem(height: 60.size, child: Text('Header')), FlexItem(flexGrow: 1, child: Text('Content Area')), FlexItem(height: 40.size, child: Text('Footer')), ], ) // Reverse direction layouts RowBox.reverse( justifyContent: BoxAlignmentBase.end, children: [ FlexItem(child: Text('Right')), FlexItem(child: Text('Left')), ], ) ColumnBox.reverse( children: [ FlexItem(child: Text('Bottom')), FlexItem(child: Text('Top')), ], ) ``` -------------------------------- ### Flutter: Basic Horizontal Flex Layout with FlexBox Source: https://context7.com/sunarya-thito/flexbox/llms.txt Demonstrates a basic horizontal flex layout using the FlexBox widget. It showcases properties like direction, wrap, alignment, justification, padding, and gap. The example includes FlexItem widgets with grow, fixed width, and different grow factors. ```dart import 'package:flexiblebox/flexiblebox_flutter.dart'; import 'package:flexiblebox/flexiblebox_extensions.dart'; import 'package:flutter/material.dart'; // Basic horizontal flex layout with spacing and alignment FlexBox( direction: FlexDirection.row, wrap: FlexWrap.wrap, alignItems: BoxAlignmentGeometry.center, justifyContent: BoxAlignmentBase.spaceBetween, padding: EdgeSpacing.all(16.spacing), rowGap: 8.spacing, columnGap: 12.spacing, children: [ FlexItem( flexGrow: 1.0, child: Container( color: Colors.red, height: 100, child: Center(child: Text('Grows')), ), ), FlexItem( width: 150.size, child: Container( color: Colors.blue, height: 100, child: Center(child: Text('Fixed 150px')), ), ), FlexItem( flexGrow: 2.0, child: Container( color: Colors.green, height: 100, child: Center(child: Text('Grows 2x')), ), ), ], ) ``` -------------------------------- ### Flexbox Alignment Options in Dart Source: https://context7.com/sunarya-thito/flexbox/llms.txt Demonstrates how to control item positioning along main and cross axes using Flexbox in Dart. Includes examples for justifyContent, alignItems, alignContent, and alignSelf properties. Dependencies include FlexBox, FlexItem, BoxAlignmentBase, BoxAlignmentGeometry, BoxAlignmentContent, and FlexWrap. ```dart FlexBox( direction: FlexDirection.row, justifyContent: BoxAlignmentBase.spaceBetween, // space-between children: [ FlexItem(child: Text('Start')), FlexItem(child: Text('End')), ], ) // Available justifyContent values: // - BoxAlignmentBase.start // - BoxAlignmentBase.center // - BoxAlignmentBase.end // - BoxAlignmentBase.spaceBetween // - BoxAlignmentBase.spaceAround // - BoxAlignmentBase.spaceEvenly // Cross axis alignment (alignItems) FlexBox( direction: FlexDirection.row, alignItems: BoxAlignmentGeometry.center, // center children: [ FlexItem(height: 100.size, child: Text('Tall')), FlexItem(height: 50.size, child: Text('Short')), ], ) // Available alignItems values: // - BoxAlignmentGeometry.start // - BoxAlignmentGeometry.center // - BoxAlignmentGeometry.end // - BoxAlignmentGeometry.stretch // - BoxAlignmentGeometry.baseline // Multi-line content alignment (alignContent) FlexBox( direction: FlexDirection.row, wrap: FlexWrap.wrap, alignContent: BoxAlignmentContent.spaceBetween, children: [/* many items */], ) // Individual item override FlexBox( alignItems: BoxAlignmentGeometry.start, children: [ FlexItem(child: Text('Uses parent alignment')), FlexItem( alignSelf: BoxAlignmentGeometry.center, // Override for this item child: Text('Centered'), ), FlexItem( alignSelf: BoxAlignmentGeometry.end, child: Text('End-aligned'), ), ], ) ``` -------------------------------- ### Sticky Headers and Footers with Flexbox in Dart Source: https://context7.com/sunarya-thito/flexbox/llms.txt Implements sticky headers and footers within a scrollable container using Flexbox in Dart. The example utilizes FlexItem with top, left, and right positioning properties to create fixed elements during scrolling. Requires SizedBox for height constraint and LayoutOverflow.scroll for enabling vertical scrolling. ```dart SizedBox( height: 300, // Constrains height to enable scrolling child: FlexBox( direction: FlexDirection.column, verticalOverflow: LayoutOverflow.scroll, children: [ // Sticky header that sticks to top FlexItem( top: 0.position, left: 0.position, right: 0.position, height: 50.size, child: Container( color: Colors.blue, child: Center( child: Text('Sticky Header', style: TextStyle(color: Colors.white)), ), ), ), // Regular scrollable content FlexItem( height: 150.size, child: Container(color: Colors.grey[300], child: Text('Content 1')), ), FlexItem( height: 200.size, child: Container(color: Colors.grey[400], child: Text('Content 2')), ), FlexItem( height: 200.size, child: Container(color: Colors.grey[300], child: Text('Content 3')), ), // Sticky footer that sticks to bottom FlexItem( bottom: 0.position, left: 0.position, right: 0.position, height: 50.size, child: Container( color: Colors.red, child: Center( child: Text('Sticky Footer', style: TextStyle(color: Colors.white)), ), ), ), ], ), ) ``` -------------------------------- ### Customizable Scrollbars with Flexbox in Dart Source: https://context7.com/sunarya-thito/flexbox/llms.txt Shows how to add and customize scrollbars for Flexbox containers in Dart. Includes examples for basic scrollbars, custom scrollbar styling (thumb color, border radius, margins), and programmatic scroll control using ScrollController. Dependencies include Scrollbars, FlexBox, FlexItem, and ScrollController. ```dart // Basic scrollbar SizedBox( width: 400, height: 300, child: Scrollbars( child: FlexBox( direction: FlexDirection.column, children: [ for (int i = 0; i < 20; i++) // Loop to create multiple items for scrolling FlexItem( height: 80.size, child: Container( margin: EdgeInsets.all(8), color: Colors.primaries[i % Colors.primaries.length], child: Center(child: Text('Item $i')), ), ), ], ), ), ) // Custom scrollbar styling Scrollbars( verticalScrollbar: DefaultScrollbar( thumbDecoration: BoxDecoration( color: Colors.blue.withOpacity(0.5), borderRadius: BorderRadius.circular(4), ), thumbActiveDecoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(4), ), minThumbLength: 48.0, margin: EdgeInsets.all(2), ), horizontalScrollbar: DefaultScrollbar( thumbDecoration: BoxDecoration( color: Colors.green.withOpacity(0.5), borderRadius: BorderRadius.circular(4), ), ), verticalScrollbarThickness: 12, horizontalScrollbarThickness: 12, child: FlexBox( direction: FlexDirection.row, horizontalOverflow: LayoutOverflow.scroll, verticalOverflow: LayoutOverflow.scroll, children: [/* content */], ), ) // Programmatic scroll control final scrollController = ScrollController(); Scrollbars( child: FlexBox( verticalController: scrollController, verticalOverflow: LayoutOverflow.scroll, children: [/* content */], ), ) // Later: scrollController.animateTo(100, duration: Duration(milliseconds: 300), curve: Curves.easeOut); ``` -------------------------------- ### Running the Flexbox Demo Application Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Commands to navigate to the demo directory and run the interactive demo application using Flutter. This allows for visual inspection of the flexbox layout features. ```bash ```bash cd demo flutter run ``` ``` -------------------------------- ### CMake Function for Standard Compilation Settings Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features and options to a target. This includes setting C++ standard to 17, enabling specific warning levels, and defining preprocessor macros. ```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 Subdirectory and Plugin Integration Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/CMakeLists.txt Includes Flutter's managed directory and the application's runner subdirectory. It also includes generated plugin build rules, which are essential for integrating third-party plugins into the Flutter application. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Set up Flutter dependencies and build rules in CMake Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/CMakeLists.txt Adds the Flutter managed directory, locates GTK via pkg‑config, includes generated plugin definitions, adds the runner subdirectory, and creates a dependency on the Flutter assemble step. Also configures the runtime output location to avoid accidental execution of the unbundled binary. ```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_subdirectory("runner") add_dependencies(${BINARY_NAME} flutter_assemble) set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Running Flutter Tests Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Command to execute all tests within the Flutter project. Ensure you are in the project's root directory before running this command. ```bash ```bash flutter test ``` ``` -------------------------------- ### Configure Flutter Library Paths and Targets (CMake) Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/flutter/CMakeLists.txt Sets up the Flutter library path, header files, and creates an interface library target for Flutter. It also defines dependencies for the assembly target. ```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") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === 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) ``` -------------------------------- ### Configure C++ Wrapper Libraries (CMake) Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/flutter/CMakeLists.txt Defines static C++ wrapper libraries for Flutter plugins and applications. It includes necessary source files and links against the Flutter library, setting up include directories and visibility. ```cmake # === 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 C++ Application Build with CMake Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/runner/CMakeLists.txt This CMake script configures the build for a C++ application. It defines the executable name, adds source files, applies standard build settings, sets preprocessor definitions for the application ID, and links against Flutter and GTK libraries. It also specifies include directories. ```cmake cmake_minimum_required(VERSION 3.13) 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} "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}) # Add preprocessor definitions for the application ID. add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Configure Flutter Library Headers List Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Creates a list of Flutter engine header files and prepends the ephemeral directory path to each header location. This prepares the include paths for compilation. ```cmake 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/") ``` -------------------------------- ### Find GTK and GLIB System Dependencies Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Uses PkgConfig to locate required system libraries for Flutter Linux: GTK 3.0 for UI, GLib 2.0 for core functionality, and GIO for I/O operations. These are imported as CMake targets. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Configure Flutter CMake Project Source: https://github.com/sunarya-thito/flexbox/blob/master/example/windows/CMakeLists.txt Sets up the minimum CMake version, project name, and binary executable name for a Flutter application. It defines the project as using C++ and establishes the binary name for the on-disk executable. This snippet is foundational for the build system and has no dependencies, taking no inputs but defining global build variables. ```CMake # Project-level configuration. cmake_minimum_required(VERSION 3.14) project(example 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") ``` -------------------------------- ### Define Flutter INTERFACE Library Target Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Creates an INTERFACE library for Flutter that configures include directories and links against the Flutter engine library and system dependencies. Sets up build dependencies on the flutter_assemble target. ```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 ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Git Branching and Committing Workflow Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Standard Git commands for contributing to the project. This includes creating a new feature branch, committing changes, and pushing the branch to the remote repository for a pull request. ```bash ```bash git checkout -b feature/amazing-feature git commit -m 'Add amazing feature' git push origin feature/amazing-feature ``` ``` -------------------------------- ### Create Custom Build Command for Flutter Assembly Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Defines a custom build command that runs the Flutter tool backend script to generate the Flutter library and headers. Uses a phony output to ensure the command runs on every build. Creates a custom target to drive this command. ```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} ) ``` -------------------------------- ### Define Flutter Tool Backend Command (CMake) Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/flutter/CMakeLists.txt Configures a custom command to execute the Flutter tool backend script. This command is designed to run every time by using a phony output file, ensuring dynamic build artifacts are generated. ```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" ${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} ) ``` -------------------------------- ### Configure CMake Minimum Version and Flutter Environment Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Sets the minimum CMake version and defines the ephemeral directory for Flutter-generated files. Includes the generated configuration that provides build settings from the Flutter tool. ```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) ``` -------------------------------- ### Dart Extension Methods for FlexibleBox Units Source: https://github.com/sunarya-thito/flexbox/blob/master/README.md Shows how to use extension methods on int and double for creating size, position, and spacing units in the flexiblebox package. This enhances code readability and conciseness compared to explicit unit instantiation. ```dart import 'package:flexiblebox/flexiblebox_extensions.dart'; // Size units 100.size // SizeUnit.fixed(100.0) 50.0.size // SizeUnit.fixed(50.0) 0.5.relativeSize // SizeUnit.viewportSize * 0.5 (50% of viewport) // Position units 10.position // PositionUnit.fixed(10.0) 20.0.position // PositionUnit.fixed(20.0) 0.25.relativePosition // PositionUnit.viewportSize * 0.25 (25% of viewport) // Spacing units 8.spacing // SpacingUnit.fixed(8.0) 16.0.spacing // SpacingUnit.fixed(16.0) 0.1.relativeSpacing // SpacingUnit.viewportSize * 0.1 (10% of viewport) // Percentage helper 50.percent // 0.5 (useful for calculations) ``` -------------------------------- ### Flutter: FlexItem Configuration for Sizing and Alignment Source: https://context7.com/sunarya-thito/flexbox/llms.txt Illustrates various configurations for the FlexItem widget, controlling its flex grow/shrink behavior, minimum and maximum widths, height, and self-alignment. It also shows how to set an aspect ratio and use a builder for dynamic content. ```dart // Flexible item with grow/shrink and constraints FlexItem( flexGrow: 1.0, flexShrink: 0.5, minWidth: 100.size, maxWidth: 400.size, height: 80.size, alignSelf: BoxAlignmentGeometry.center, child: Container( color: Colors.purple, child: Center(child: Text('Flexible Item')), ), ) // Item with aspect ratio constraint FlexItem( width: 200.size, aspectRatio: 16 / 9, // Maintains 16:9 ratio child: Container( color: Colors.orange, child: Center(child: Text('16:9 Aspect')), ), ) // Builder variant with layout information FlexItem.builder( flexGrow: 1.0, builder: (context, layoutBox) { return Container( color: Colors.teal, child: Text('Viewport: ${layoutBox.viewportSize.width.toStringAsFixed(0)}px'), ); }, ) ``` -------------------------------- ### Configure CMake project for Flutter Linux runner Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/CMakeLists.txt Sets the minimum CMake version, defines the project name and language, configures the binary name and GTK application ID, applies modern CMake policies, sets runtime library search paths, and handles optional sysroot configuration for cross‑building environments. ```CMake cmake_minimum_required(VERSION 3.13) 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") 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() ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/sunarya-thito/flexbox/blob/master/example/windows/CMakeLists.txt Defines a function to apply standard compilation settings to targets, including C++17 features, warning levels, and exception handling options. It sets definitions for exceptions and debug modes. This function is used by default on plugins and most targets, with caution advised for adding new options as they affect multiple components. ```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_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 Configuration for Flutter Executable Source: https://github.com/sunarya-thito/flexbox/blob/master/demo/windows/runner/CMakeLists.txt Defines the main executable target for a Flutter application using CMake. It lists all necessary source files, including C++ files, generated files, and resource files. This configuration ensures the application can be built correctly by CMake. ```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) ``` -------------------------------- ### Integrate Flutter Library and Runner Source: https://github.com/sunarya-thito/flexbox/blob/master/example/windows/CMakeLists.txt Adds Flutter managed directory and runner subdirectory to the build, including generated plugin build rules. This integrates Flutter's build system and application runner. It requires the flutter subdirectory and generated plugins file to exist, outputting built libraries and executables. ```CMake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define Custom list_prepend CMake Function Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/flutter/CMakeLists.txt Implements a compatibility function to prepend a prefix to each element in a list. This provides functionality similar to list(TRANSFORM ... PREPEND ...) which is not available in CMake 3.10. ```cmake # Serves the same purpose as list(TRANSFORM ... PREPEND ...), # which isn't available in 3.10. 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() ``` -------------------------------- ### Define standard compile settings for CMake targets Source: https://github.com/sunarya-thito/flexbox/blob/master/example/linux/CMakeLists.txt Provides a reusable function that enforces C++14, enables all warnings as errors, adds optimization flags for non‑debug builds, and defines NDEBUG when not debugging. Targets can invoke this function to maintain consistent build options. ```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() ```