### Install Application Runtime Components Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/CMakeLists.txt Configures the installation process for the application on Windows. It sets the installation prefix relative to the executable, 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) ``` -------------------------------- ### CMake Installation Configuration for Runtime Bundle Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Sets up the installation process for creating a relocatable runtime bundle. It defines installation directories for data and libraries, installs the main executable, Flutter ICU data, Flutter library, and bundled plugin libraries. ```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) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and executable binary name. It also enables modern CMake behaviors and defines build configuration types based on whether the generator is multi-config. ```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() ``` -------------------------------- ### Install Flutter Assets using CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Configures the installation of Flutter assets by first removing any existing assets and then copying the new assets from the build directory to the installation bundle data directory. This ensures that the correct assets are present in the deployed application. ```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) ``` -------------------------------- ### CMake Installation of Native Assets Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Installs native assets provided by the build.dart script from all packages into the application's bundle. This ensures that any platform-specific assets are correctly deployed. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Project Configuration and Settings Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Sets up the basic project structure, including minimum CMake version, project name, executable name, and application ID. It also configures modern CMake behaviors and installation paths for bundled libraries. ```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 Flutter Managed Directory and PkgConfig Setup Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Sets the path for Flutter managed files and checks for GTK development files using PkgConfig. This is crucial for integrating Flutter with native GTK applications. ```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}") ``` -------------------------------- ### GetxLogicPutStateMixin: Stateful Controller Management (Dart) Source: https://context7.com/linxunfeng/getx_helper/llms.txt This mixin simplifies GetX controller lifecycle management within StateWidgets. It provides automatic controller initialization, disposal, and tag synchronization with the widget's lifecycle. It requires implementing initLogic() for controller creation and optionally customLogicTag() for specific tag assignments. Dependencies include 'flutter' and 'get'. ```dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:getx_helper/getx_helper.dart'; class ProfileLogic extends GetxController { String userName = 'John Doe'; void updateName(String newName) { userName = newName; update(); } } class ProfilePage extends StatefulWidget { const ProfilePage({super.key}); @override State createState() => _ProfilePageState(); } class _ProfilePageState extends State with GetxLogicPutStateMixin { @override ProfileLogic initLogic() => ProfileLogic(); @override String? customLogicTag() { // Return null for auto-generated tag, or provide custom tag return null; } @override Widget buildBody(BuildContext context) { return GetBuilder( tag: logicTag, builder: (_) { return Scaffold( appBar: AppBar(title: Text('Profile')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('User: ${logic.userName}'), SizedBox(height: 20), ElevatedButton( onPressed: () => logic.updateName('Jane Smith'), child: Text('Change Name'), ), ], ), ), ); }, ); } } ``` -------------------------------- ### GetxLogicProvider: Manage GetX Controller Lifecycle (Dart) Source: https://context7.com/linxunfeng/getx_helper/llms.txt The GetxLogicProvider widget automatically manages the lifecycle and tag propagation of GetX controllers within the widget tree. It takes a controller factory and a child widget, ensuring controllers are properly created, disposed of, and accessible via their tags. Dependencies include 'flutter' and 'get'. ```dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:getx_helper/getx_helper.dart'; // Define your controller class CounterLogic extends GetxController { int count = 0; void increment() { count++; update(); } } // Use GetxLogicProvider.put to automatically create and register the controller class CounterPage extends StatelessWidget { @override Widget build(BuildContext context) { return GetxLogicProvider.put( CounterLogic.new, child: Scaffold( appBar: AppBar(title: Text('Counter')), body: GetxLogicConsumer.get( CounterLogic.new, builder: (context, logic, logicTag) { return GetBuilder( tag: logicTag, builder: (_) => Center( child: Text('Count: ${logic.count}'), ), ); }, ), floatingActionButton: GetxLogicConsumer.get( CounterLogic.new, builder: (context, logic, logicTag) { return FloatingActionButton( onPressed: logic.increment, child: Icon(Icons.add), ); }, ), ), ); } } ``` -------------------------------- ### VSCode Extension Configuration for GetX Helper Source: https://context7.com/linxunfeng/getx_helper/llms.txt This JSON snippet represents a VSCode extension configuration option for the GetX Helper. Specifically, it controls the 'autoSetAssignId' feature, which is set to 'false' in this example, indicating that unique IDs for controllers will not be automatically assigned. ```json { "fullstackaction-getx-helper.autoSetAssignId": false } ``` -------------------------------- ### Install AOT Library Conditionally using CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library only for non-debug build configurations. This helps in optimizing performance for release builds by including the pre-compiled library, while omitting it for debug builds to potentially reduce build times or binary size. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Define Profile Build Mode Settings Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/CMakeLists.txt Sets linker and compiler flags for the 'Profile' build configuration by copying settings from the 'Release' configuration. This ensures consistent performance optimizations for profiling. ```cmake set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### GH_GetxLogicProvider.put Snippet for Controller Instantiation Source: https://context7.com/linxunfeng/getx_helper/llms.txt This snippet demonstrates how to use GetxLogicProvider.put to instantiate and provide a Logic controller to the widget tree. It takes the controller's constructor and a 'child' widget as arguments. This is the primary method for making a controller available to its descendants. ```dart GetxLogicProvider.put( Logic.new, child: Widget, ); ``` -------------------------------- ### VSCode GetX Page Generation Commands Source: https://context7.com/linxunfeng/getx_helper/llms.txt Details VSCode extension commands for generating GetX page structures, ensuring proper tag management. The 'GetX: Simple Page' command allows users to right-click a folder, input a page name, and receive a generated file structure including header, logic, page, and state components. ```bash # Command 1: Generate Simple GetX Page # Right-click on a folder in VSCode Explorer and select "GetX: Simple Page" # Input: page name in snake_case (e.g., "user_profile") # Generates structure: # user_profile/ # ├── header/ # │ └── user_profile_header.dart # ├── logic/ # │ └── user_profile_logic.dart # ├── page/ # │ └── user_profile_page.dart # └── state/ ``` -------------------------------- ### Apply Standard Compilation Settings Function Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features, options, and definitions to a target. This includes C++17 standard, warning level 4, error-on-warning, exception handling settings, and debug definitions. ```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() ``` -------------------------------- ### Find GTK, GLIB, and GIO Dependencies Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required GTK, GLIB, and GIO libraries. This ensures that the necessary system-level dependencies are available for the Flutter Linux application. It imports targets for these packages, making them available 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) ``` -------------------------------- ### Include Flutter and Runner Subdirectories Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, essential for building the Flutter application and its components. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") ``` -------------------------------- ### Configure Executable Target and Source Files (CMake) Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/runner/CMakeLists.txt Defines the main executable target for the application and lists all necessary source files. This includes C++ source files, Flutter's generated plugin registrant, and Windows resource files. Ensure all project source files are correctly listed here. ```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" ) apply_standard_settings(${BINARY_NAME}) 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}") target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 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}") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Sets up a custom CMake command to execute the Flutter tool backend script. This command is designed to run every time due to the use of a `_phony_` output file, as there's no reliable way to determine the exact inputs and outputs of the Flutter tool. It passes environment variables and build parameters to the script. ```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 ) ``` -------------------------------- ### Integrate Flutter Tool Backend Assembly in CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/flutter/CMakeLists.txt This CMake snippet sets up a custom command to execute the Flutter tool backend script for assembly. It defines output targets and uses environment variables to pass necessary information to the tool. A phony target ensures the command runs on every build, as direct input/output tracking is not available. ```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} ) ``` -------------------------------- ### Access GetX Controllers with Extensions Source: https://context7.com/linxunfeng/getx_helper/llms.txt Demonstrates using `getxLogic` extension methods to access GetX controllers from `BuildContext` or `State`. It handles automatic tag resolution, simplifying controller access in widgets. Dependencies include `flutter/material.dart`, `get/get.dart`, and `getx_helper/getx_helper.dart`. ```dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:getx_helper/getx_helper.dart'; class SettingsLogic extends GetxController { bool darkMode = false; void toggleTheme() { darkMode = !darkMode; update(); } } class SettingsWidget extends StatefulWidget { @override State createState() => _SettingsWidgetState(); } class _SettingsWidgetState extends State with GetxLogicConsumerStateMixin { @override void initState() { super.initState(); // Access logic using getxLogic extension final currentMode = getxLogic().darkMode; print('Current dark mode: $currentMode'); } @override Widget build(BuildContext context) { // Access logic using context extension final logic = context.getxLogic(); return GetBuilder( tag: logicTag, builder: (_) { return SwitchListTile( title: Text('Dark Mode'), value: logic.darkMode, onChanged: (_) => logic.toggleTheme(), ); }, ); } } ``` -------------------------------- ### Configure C++ Wrapper for Flutter Plugins in CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/flutter/CMakeLists.txt This CMake snippet defines a static library for the Flutter C++ wrapper used by plugins. It includes core implementation files and plugin-specific sources. It sets properties like `POSITION_INDEPENDENT_CODE` and `CXX_VISIBILITY_PRESET`, links against the main Flutter library, and specifies include directories. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") # 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) ``` -------------------------------- ### Create Flutter Interface Library Target Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Defines an interface library target named `flutter`. This target includes the Flutter engine library and header directories, as well as linking against the found GTK, GLIB, and GIO libraries. It also adds a dependency on the `flutter_assemble` target. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### CMake Application Executable Definition Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Defines the main application executable target, including source files like main.cc, my_application.cc, and generated plugin registration code. It also 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) ``` -------------------------------- ### Configure C++ Wrapper for Flutter Application Runner in CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/flutter/CMakeLists.txt This CMake snippet defines a static library for the Flutter C++ wrapper used by the application runner. It includes core implementation files and application-specific sources. It links against the main Flutter library and specifies include directories, ensuring proper integration with the Flutter engine. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Propagate GetX Tag Context with GetxTagProvider Source: https://context7.com/linxunfeng/getx_helper/llms.txt Introduces `GetxTagProvider`, a widget that supplies tag context to its descendants, enabling automatic tag propagation for GetX controllers. This eliminates the need for manual tag management. It requires `flutter/material.dart`, `get/get.dart`, and `getx_helper/getx_helper.dart`. ```dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:getx_helper/getx_helper.dart'; class DataLogic extends GetxController { List items = ['Item 1', 'Item 2', 'Item 3']; } class DataContainer extends StatelessWidget { @override Widget build(BuildContext context) { // GetxTagProvider automatically generates and propagates tag return GetxTagProvider( onInit: (tag) { // Register controller with auto-generated tag Get.put(DataLogic(), tag: tag); }, child: Builder( builder: (context) { // Retrieve tag from context final tag = context.getxTag(); final logic = Get.find(tag: tag); return ListView.builder( itemCount: logic.items.length, itemBuilder: (context, index) { return ListTile( title: Text(logic.items[index]), ); }, ); }, ), ); } } ``` -------------------------------- ### GH_GetBuilder Snippet for GetX Logic Source: https://context7.com/linxunfeng/getx_helper/llms.txt This snippet generates a GetBuilder widget for a specified Logic controller. It utilizes a 'logicTag' for managing different instances of the same controller, essential for reactive UI updates in GetX applications. The builder function returns a basic Container, which should be replaced with the actual UI elements. ```dart GetBuilder( tag: logicTag, builder: (_) { return Container(); }, ); ``` -------------------------------- ### GH_GetxLogicConsumer.get Snippet for Controller Access Source: https://context7.com/linxunfeng/getx_helper/llms.txt This snippet shows how to access an existing Logic controller within the widget tree using GetxLogicConsumer.get. It provides the controller's constructor, a 'builder' function that receives the context, the logic instance, and the logicTag, allowing widgets to react to controller changes. ```dart GetxLogicConsumer.get( Logic.new, builder: (context, logic, logicTag) { return Widget; }, ); ``` -------------------------------- ### Configure Flutter Library and Headers in CMake Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/windows/flutter/CMakeLists.txt This snippet defines the Flutter library and its associated header files within the CMake build system. It sets the path to the Flutter library DLL and ICU data file, and lists necessary header files for interface targets. Dependencies are managed through `add_dependencies`. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 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 Runtime Output Directory Configuration Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Configures the runtime output directory for the application's executable. This ensures that the executable is placed in a specific subdirectory for proper resource loading when bundled. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Assemble Flutter Target Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Creates a custom target `flutter_assemble` that depends on the Flutter library and its header files. This target ensures that the Flutter engine components are built or made available before other targets that depend on them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### CMake Function for Standard Build Settings Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Defines a function `APPLY_STANDARD_SETTINGS` to encapsulate common compilation settings for targets. This includes setting C++ standard, warning levels, optimization levels, and NDEBUG definition based on the build configuration. ```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() ``` -------------------------------- ### CMake Plugin Build Rules Inclusion Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Includes the CMake script that manages the building of Flutter plugins and their integration into the application. This is essential for incorporating plugin functionality. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define Flutter Library and Headers Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Sets variables for the Flutter Linux GTK shared library (`libflutter_linux_gtk.so`) and its associated header files. It also defines paths for ICU data and the project build directory. These variables are crucial for linking the Flutter engine and its components. ```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) 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/") ``` -------------------------------- ### Maintain GetX Tag Context with GHHero Animation Source: https://context7.com/linxunfeng/getx_helper/llms.txt Presents the `GHHero` widget, a wrapper for Flutter's `Hero` widget designed to preserve GetX tag context during animations. This prevents potential tag-related errors in GetX-managed components. It requires `flutter/material.dart`, `get/get.dart`, and `getx_helper/getx_helper.dart`. ```dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:getx_helper/getx_helper.dart'; class ProductLogic extends GetxController { String productName = 'Sample Product'; double price = 99.99; } class ProductListItem extends StatelessWidget { final String logicTag; final String productId; const ProductListItem({ required this.logicTag, required this.productId, }); @override Widget build(BuildContext context) { return GHHero( tag: 'product_$productId', logicTag: logicTag, child: Card( child: GetBuilder( tag: logicTag, builder: (logic) { return ListTile( title: Text(logic.productName), subtitle: Text('$${logic.price}'); onTap: () { Get.toNamed('/product-detail', arguments: { 'logicTag': logicTag, 'productId': productId, }); }, ); }, ), ), ); } } ``` -------------------------------- ### Custom CMake List Prepend Function Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/flutter/CMakeLists.txt Defines a custom CMake function `list_prepend` to prepend a prefix to each element in a list. This is used because the `list(TRANSFORM ... PREPEND ...)` command is not available in CMake version 3.10. It takes the list name and the prefix as arguments and modifies the 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/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Defines the build type (Debug, Profile, Release) for the project if not already set. This ensures a consistent build configuration for Flutter applications. ```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() ``` -------------------------------- ### CMake Cross-Building Configuration Source: https://github.com/linxunfeng/getx_helper/blob/main/flutter/example/linux/CMakeLists.txt Configures CMake for cross-building by setting the sysroot and find root paths. It also sets modes for how CMake searches for programs, packages, libraries, and include files when cross-compiling. ```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() ``` -------------------------------- ### Generate Unique Tags with GetxUtils Source: https://context7.com/linxunfeng/getx_helper/llms.txt Explains the use of `GetxUtils.uniqueTag()` for generating unique identifiers to prevent conflicts between GetX controller instances. This utility can generate tags with a default number of random digits or a custom count. It depends on `getx_helper/getx_helper.dart`. ```dart import 'package:getx_helper/getx_helper.dart'; void main() { // Generate unique tag with default count (3 random digits) String tag1 = GetxUtils.uniqueTag(); print('Tag 1: $tag1'); // Output: 3241702345678901234 // Generate unique tag with custom random digit count String tag2 = GetxUtils.uniqueTag(count: 5); print('Tag 2: $tag2'); // Output: 456781702345678901234 // Use in controller registration final myController = MyController(); final uniqueTag = GetxUtils.uniqueTag(); Get.put(myController, tag: uniqueTag); // Later retrieve with the same tag final retrieved = Get.find(tag: uniqueTag); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.