### Installation Rules for Runtime Components Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Configures the installation process, setting the installation prefix to the executable's directory and defining destinations for runtime components, libraries, and native assets. It ensures that support files are placed correctly for the application to run. ```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 Project Setup and Configuration Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and defines core properties like binary name and application ID. It also configures modern CMake behaviors and installation paths. ```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") ``` -------------------------------- ### Migration Guide: June 0.8.x to 1.0.0 Source: https://github.com/melodysdreamj/june/blob/main/README.md Provides a clear before-and-after comparison for migrating state retrieval in the June library. It highlights the change in how to get the state instance, moving from passing the class directly to using a factory function. ```dart /// Before June.getState(CounterVM()); /// After June.getState(() => CounterVM()); ``` -------------------------------- ### Installation Rules for Application Bundle Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It cleans the bundle directory, installs the executable, Flutter ICU data, the Flutter library, bundled plugin libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif () install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach (bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach (bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Sets up the CMake project, defines the minimum required version, project name, executable name, and configures build types and policies. It also handles multi-configuration generators and defines standard compilation settings. ```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 () ``` -------------------------------- ### CMake Project Setup and Executable Definition Source: https://github.com/melodysdreamj/june/blob/main/example/windows/runner/CMakeLists.txt Configures the CMake project, sets the minimum required version, and defines the main executable target 'runner'. It lists all source files, including C++ files, generated plugin registration, and resource files, required to build the application. ```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" ) ``` -------------------------------- ### Flutter Library Setup Source: https://github.com/melodysdreamj/june/blob/main/example/windows/flutter/CMakeLists.txt Configures the Flutter library, including its DLL and header files, and links it to the main project. It also sets up ICU data file and project build directory paths. ```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) ``` -------------------------------- ### Flutter Linux GTK Library Setup Source: https://github.com/melodysdreamj/june/blob/main/example/linux/flutter/CMakeLists.txt Configures the Flutter library for Linux GTK. It finds PkgConfig modules for GTK, GLIB, and GIO, sets the Flutter library path, and defines include directories and link libraries for the 'flutter' target. ```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) ``` -------------------------------- ### Conditional AOT Library Installation in CMake Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt This CMake code snippet handles the installation of the Ahead-Of-Time (AOT) compiled library. The library is only installed for builds that are not in 'Debug' mode, ensuring optimized performance for release builds. ```cmake if (NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif () ``` -------------------------------- ### Basic June State Management Example Source: https://github.com/melodysdreamj/june/blob/main/README.md Demonstrates the basic usage of the June state management library in a Flutter application. It shows how to create and update a state object (CounterVM) and display its properties in the UI using JuneBuilder. Includes buttons to increment the counter. ```dart import 'package:flutter/material.dart'; import 'package:june/june.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ JuneBuilder( () => CounterVM(), builder: (vm) => Column( children: [ const Text('Basic instance counter'), Text( '${vm.count}', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), JuneBuilder( () => CounterVM(), tag: "SomeId", builder: (vm) => Column( children: [ const Text('Object instance counter created with tags'), Text( '${vm.count}', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), ], ), ), floatingActionButton: const Stack( children: [ Positioned( right: 0, bottom: 80, child: FloatingActionButton.extended( onPressed: increaseBasicInstance, label: Text("Increase basic instance"))), Positioned( right: 0, bottom: 10, child: FloatingActionButton.extended( onPressed: increaseObjectInstanceCreatedWithTags, label: Text("Increase object instance created with tags"))), ], ), ), ); } } void increaseBasicInstance() { var state = June.getState(() => CounterVM()); state.count++; state.setState(); } void increaseObjectInstanceCreatedWithTags() { var state = June.getState(() => CounterVM(), tag: "SomeId"); state.count++; state.setState(); } class CounterVM extends JuneState { int count = 0; } ``` -------------------------------- ### Asset Directory Management in CMake Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt This snippet configures CMake to manage the Flutter asset directory. It ensures the asset directory is completely re-copied on each build to prevent stale files from previous installations. It defines the asset directory name and then removes the existing directory before installing the new one. ```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 ) ``` -------------------------------- ### Counter with Actions Inside Model Source: https://github.com/melodysdreamj/june/blob/main/README.md This example shows how to define and call actions directly within the state model. The `incrementCounter` method is part of the `CounterVM` class and is invoked from the `FloatingActionButton`'s `onPressed` callback. ```dart import 'package:flutter/material.dart'; import 'package:june/june.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: JuneBuilder( () => CounterVM(), builder: (vm) => Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('You have pushed the button this many times:'), Text( '${vm.count}', style: Theme .of(context) .textTheme .headlineMedium, ), ], ), ), ), floatingActionButton: FloatingActionButton( onPressed: () { // This way, you can call actions inside the model. June.getState(() => CounterVM()).incrementCounter(); }, child: const Icon(Icons.add), ), ), ); } } class CounterVM extends JuneState { int count = 0; // You can also create actions inside the model. incrementCounter() { count++; setState(); } } ``` -------------------------------- ### Flutter Service Worker Initialization Source: https://github.com/melodysdreamj/june/blob/main/example/web/index.html This snippet demonstrates how the Flutter application is initialized using a service worker. It loads the main Dart entry point and sets up the engine initializer. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Configures linker and compiler flags for the 'Profile' build mode, mirroring the settings from the 'Release' build mode. ```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}") ``` -------------------------------- ### Plugin Build Rules Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Includes generated CMake files that manage the building of plugins and their integration into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Executable Target Definition and Linking Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Defines the main executable target, including source files and generated files. It applies standard settings, links necessary libraries (Flutter, GTK), and adds build dependencies. ```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) ``` -------------------------------- ### Build Type and Cross-Building Configuration Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Configures the build type (Debug, Profile, Release) if not already set and handles cross-building scenarios by setting the sysroot and find root paths. ```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 () 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 () ``` -------------------------------- ### Unicode Support and Standard Compilation Settings Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Enables Unicode support by defining preprocessor macros and applies standard compilation features and options to targets. This includes setting the C++ standard to C++17 and configuring warning levels and exception handling. ```cmake add_definitions(-DUNICODE -D_UNICODE) 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 Library and Include Directory Dependencies Source: https://github.com/melodysdreamj/june/blob/main/example/windows/runner/CMakeLists.txt Links necessary libraries, including Flutter-specific libraries and Windows system libraries like 'dwmapi.lib', to the application target. It also specifies the include directories required for the project. ```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}") ``` -------------------------------- ### Flutter and System Dependency Integration Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Includes the Flutter managed directory and finds system-level dependencies like GTK using PkgConfig. 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}") ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, warnings, optimization levels, and definitions to targets. ```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() ``` -------------------------------- ### Flutter Tool Backend Integration Source: https://github.com/melodysdreamj/june/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend script for building and assembling Flutter resources. It uses a phony target to ensure the command runs on every build. ```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} ) ``` -------------------------------- ### Runtime Output Directory Configuration Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a specific subdirectory to ensure correct execution within a bundled application structure. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### C++ Wrapper for Plugins Source: https://github.com/melodysdreamj/june/blob/main/example/windows/flutter/CMakeLists.txt Defines a static library for the C++ client wrapper used by Flutter plugins. It includes core implementations and plugin registrar sources, linking against the Flutter library. ```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) ``` -------------------------------- ### CMake Build Settings and Preprocessor Definitions Source: https://github.com/melodysdreamj/june/blob/main/example/windows/runner/CMakeLists.txt Applies standard build settings to the executable and defines preprocessor macros for various components of the Flutter version. This ensures that version information is available during compilation. ```cmake # 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") ``` -------------------------------- ### Subdirectory Inclusion for Flutter and Runner Source: https://github.com/melodysdreamj/june/blob/main/example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, which are essential for building the application's Flutter components and runner logic. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") ``` -------------------------------- ### Customize Launch Screen via Xcode Source: https://github.com/melodysdreamj/june/blob/main/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md Instructions for customizing the launch screen assets by opening the Flutter project's Xcode workspace, selecting the Assets.xcassets catalog, and dropping in new images. ```bash open ios/Runner.xcworkspace ``` -------------------------------- ### C++ Wrapper for Runner Source: https://github.com/melodysdreamj/june/blob/main/example/windows/flutter/CMakeLists.txt Defines a static library for the C++ client wrapper used by the Flutter runner application. It includes core implementations and application-specific sources, linking against the Flutter library. ```cmake # 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) ``` -------------------------------- ### Plugin Build Rules Inclusion Source: https://github.com/melodysdreamj/june/blob/main/example/linux/CMakeLists.txt Includes the CMake script responsible for managing the build rules of Flutter plugins and integrating them into the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/melodysdreamj/june/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command is responsible for generating the Flutter library and header files. It uses a phony target to ensure it runs on every build. ```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. 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} ) ``` -------------------------------- ### Manage State with JuneBuilder Source: https://github.com/melodysdreamj/june/blob/main/README.md Shows how to use JuneBuilder to wrap widgets and manage state updates. The builder function receives the state ViewModel (vm) to access and display state properties. ```dart JuneBuilder( () => CounterVM(), builder: (vm) => Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('${vm.count}') ], ), ) ``` -------------------------------- ### Basic Counter with June Source: https://github.com/melodysdreamj/june/blob/main/README.md Demonstrates a simple counter application using June for state management. It shows how to initialize a state, update a counter value, and display it in the UI. The `incrementCounter` function is called via a FloatingActionButton. ```dart import 'package:flutter/material.dart'; import 'package:june/june.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: JuneBuilder( () => CounterVM(), builder: (vm) => Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('You have pushed the button this many times:'), Text( '${vm.count}', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), ), floatingActionButton: const FloatingActionButton( onPressed: incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), ), ); } } void incrementCounter() { // You can call state from anywhere. var state = June.getState(() => CounterVM()); state.count++; state.setState(); } class CounterVM extends JuneState { int count = 0; } ``` -------------------------------- ### Update State using June.getState and setState Source: https://github.com/melodysdreamj/june/blob/main/README.md Illustrates how to access and update state from anywhere in the application using June.getState and the setState method to trigger UI updates. ```dart var state = June.getState(() => CounterVM()); state.count++; state.setState(); ``` -------------------------------- ### CMake List Prepend Function Source: https://github.com/melodysdreamj/june/blob/main/example/linux/flutter/CMakeLists.txt A custom CMake function to prepend a prefix to each element in a list. This is used as an alternative to `list(TRANSFORM ... PREPEND ...)` which is not available in CMake version 3.10. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach (element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach (element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Declare State with June Source: https://github.com/melodysdreamj/june/blob/main/README.md Demonstrates how to declare a state variable using JuneState. This serves as the ViewModel for managing state. ```dart class CounterVM extends JuneState { int count = 0; } ``` -------------------------------- ### CMake Flutter Build Artifact Dependency Source: https://github.com/melodysdreamj/june/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter build artifacts, specifically 'flutter_assemble', are built before the main application target. This is a critical step for Flutter projects to function correctly. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.