### Setup and run example project Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/README.md Commands to activate melos, clone the repository, and bootstrap the project. After these steps, open the folder in VSCode and run the super_context_menu_example launcher configuration. ```bash flutter pub global activate melos # if you don't have melos already installed git clone https://github.com/superlistapp/super_native_extensions.git cd super_native_extensions melos bootstrap ``` -------------------------------- ### Define install data and library directories Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Sets the installation directories for data and libraries within the bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install binary, ICU data, and Flutter library Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/example/linux/CMakeLists.txt Installs the application binary, ICU data file, and Flutter library to their respective bundle directories. ```cmake 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) ``` -------------------------------- ### Install bundled plugin libraries Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/example/linux/CMakeLists.txt Installs each bundled plugin library to the bundle's lib directory. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Installation rules for Windows Flutter app Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/windows/CMakeLists.txt Configures installation to copy the executable, Flutter data, libraries, native assets, and assets directory next to the executable. Installs AOT library only on Profile and Release configurations. ```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) ``` -------------------------------- ### Configure installation bundle directory and prefix Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Sets the bundle directory to ${PROJECT_BINARY_DIR}/bundle and forces CMAKE_INSTALL_PREFIX to that directory if it was not explicitly set. This makes installation produce a relocatable bundle in the build directory. ```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() ``` -------------------------------- ### Clean build bundle directory before install Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Adds an install script that removes the build bundle directory recursively before installation, ensuring a clean bundle every time. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install native assets directory Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/linux/CMakeLists.txt Installs the native assets directory from the build output to the bundle's library directory. Uses the NATIVE_ASSETS_DIR variable pointing to the build's native_assets/linux/ folder. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install executable, ICU data, Flutter library, and plugin libraries Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Installs the application executable, Flutter ICU data file, Flutter library, and all plugin bundled libraries into the appropriate bundle directories. All are assigned to the Runtime component. ```cmake 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) ``` -------------------------------- ### Install Rust on macOS or Linux Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/README.md Command to install Rust via rustup for macOS or Linux. Required if you want to compile Rust code from source instead of using precompiled binaries. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Flutter and GTK Dependencies Setup Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Sets up the build environment: adds the Flutter managed subdirectory, finds GTK-3.0 via pkg-config, and defines the APPLICATION_ID compile definition. This is required for linking against Flutter and GTK libraries on Linux. ```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}") ``` -------------------------------- ### Basic ContextMenuWidget usage Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/README.md Dart example showing how to create a context menu with ContextMenuWidget, including menu actions, separators, and nested submenus. The commented line shows how to force dark brightness. ```dart return ContextMenuWidget( // force to use dark brightness // mobileMenuWidgetBuilder: DefaultMobileMenuWidgetBuilder(brightness: Brightness.dark), child: const Item( child: Text('Base Context Menu'), ), menuProvider: (_) { return Menu( children: [ MenuAction(title: 'Menu Item 2', callback: () {}), MenuAction(title: 'Menu Item 3', callback: () {}), MenuSeparator(), Menu(title: 'Submenu', children: [ MenuAction(title: 'Submenu Item 1', callback: () {}), MenuAction(title: 'Submenu Item 2', callback: () {}), Menu(title: 'Nested Submenu', children: [ MenuAction(title: 'Submenu Item 1', callback: () {}), MenuAction(title: 'Submenu Item 2', callback: () {}), ]), ]), ], ); }, ); ``` -------------------------------- ### Flutter Windows CMake configuration Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/example/windows/CMakeLists.txt This is the complete CMake configuration for a Flutter Windows application. It sets up the project, defines build configurations (Debug, Profile, Release), applies standard compiler settings, includes Flutter and plugin build rules, and installs the application bundle with data, libraries, and native assets. The installation step is made default to support running from Visual Studio. ```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") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Define build configuration option. 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() # Define settings for the Profile build mode. 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}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # 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() # 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) # === 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) ``` -------------------------------- ### Install AOT library on non-Debug builds Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/linux/CMakeLists.txt Conditionally installs the AOT library to the bundle's library directory only when the build type is not Debug. Uses the AOT_LIBRARY variable. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install native assets, flutter_assets, and AOT library in CMake Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/example/linux/CMakeLists.txt CMake install rules for a Flutter Linux application. The first block copies native assets from the build directory into the bundle's library directory. The second block removes and re-copies the flutter_assets directory to avoid stale files. The third block installs the AOT library only when the build type is not Debug. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` ```cmake # 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) ``` ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### CMakeLists.txt for Flutter Windows build Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/example/windows/flutter/CMakeLists.txt Defines the Flutter library, C++ wrapper libraries (flutter_wrapper_plugin and flutter_wrapper_app), and the flutter_assemble custom target. Includes fallback for FLUTTER_TARGET_PLATFORM and sets parent-scope variables for install and AOT. This file should not be edited. ```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} ) ``` -------------------------------- ### CMake project configuration for Linux runner Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt This snippet sets up the CMake project for the Linux runner. It defines the minimum CMake version, project name, binary name, and application ID. It also enables modern CMake policies and sets the install RPATH to load bundled libraries. ```cmake # Project-level configuration. cmake_minimum_required(VERSION 3.10) project(runner 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") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### KeyboardLayout.getPlatformKeyCode Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/README.md Gets the platform-specific key code for a given key. ```APIDOC ## KeyboardLayout.getPlatformKeyCode ### Description Returns the platform-specific key code for either a logical or physical key. ### Method getPlatformKeyCode(dynamic key) ### Parameters - **key** (PhysicalKeyboardKey or LogicalKeyboardKey) - Required - The key to get the platform code for. ### Return Value - **int** - The platform-specific key code. ### Example ```dart final platformCode = layout.getPlatformKeyCode(PhysicalKeyboardKey.digit1); ``` ``` -------------------------------- ### Update Rust to latest version Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/README.md Command to update an existing Rust installation to the latest version. Ensures the build integration works correctly. ```bash rustup update ``` -------------------------------- ### Apply standard settings and link dependencies Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/example/linux/CMakeLists.txt Applies the standard build settings to the executable and links the Flutter library and GTK. ```cmake apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Re-copy Flutter assets directory Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/linux/CMakeLists.txt Removes the existing flutter_assets directory and installs a fresh copy from the build directory to avoid stale files. The removal is done via an install(CODE) block. ```cmake # 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) ``` -------------------------------- ### Reading from clipboard with SystemClipboard Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/README.md Shows how to read clipboard data using SystemClipboard.instance and the reader API. Checks for HTML text, plain text, and PNG formats, reading binary formats as streams. Returns early if the clipboard API is unsupported. ```dart import 'package:super_clipboard/super_clipboard.dart'; // ... final clipboard = SystemClipboard.instance; if (clipboard == null) { return; // Clipboard API is not supported on this platform. } final reader = await clipboard.read(); if (reader.canProvide(Formats.htmlText)) { final html = await reader.readValue(Formats.htmlText); // .. do something with the HTML text } if (reader.canProvide(Formats.plainText)) { final text = await reader.readValue(Formats.plainText); // Do something with the plain text } /// Binary formats need to be read as streams if (reader.canProvide(Formats.png)) { reader.getFile(Formats.png, (file) { // Do something with the PNG image final stream = file.getStream(); }); } ``` -------------------------------- ### Bootstrap the monorepo Source: https://github.com/superlistapp/super_native_extensions/blob/main/README.md Clones the repository, navigates into it, and runs melos bootstrap to set up the project. ```bash git clone https://github.com/superlistapp/super_native_extensions.git cd super_native_extensions melos bootstrap ``` -------------------------------- ### KeyboardLayoutManager.instance() Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/README.md Creates an instance of the KeyboardLayoutManager to access keyboard layout functionality. ```APIDOC ## KeyboardLayoutManager.instance() ### Description Creates and returns an instance of the KeyboardLayoutManager. The instance is used to access keyboard layout information and listen for layout changes. ### Method instance() ### Parameters None ### Return Value - **KeyboardLayoutManager** - The manager instance. ### Example ```dart final manager = await KeyboardLayoutManager.instance(); ``` ``` -------------------------------- ### HotKey.create Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_hot_key/README.md Creates a system-wide hotkey that triggers a callback when pressed, regardless of application focus. The hotkey is registered on physical keys. ```APIDOC ## HotKey.create ### Description Creates a system-wide hotkey that triggers a callback when the specified key combination is pressed, regardless of application focus. ### Method create ### Parameters - **definition** (HotKeyDefinition) - Required - The hotkey definition containing the physical key and modifier flags (alt, meta, etc.). - **callback** (Function) - Required - The callback function to be invoked when the hotkey is pressed. ### Returns - **Future** - A Future that resolves to a HotKey instance, which can be used to dispose the hotkey. ### Example dart final hotKey = await HotKey.create( definition: HotKeyDefinition( key: PhysicalKeyboardKey.minus, alt: true, meta: true, ), callback: () { print('hot key pressed'); }, ); ### Notes - Hot keys are registered on physical keys. To convert between physical and logical keys, use the super_keyboard_layout package. ``` -------------------------------- ### Apply standard settings to target Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/linux/CMakeLists.txt Applies the standard build settings to the application target. This can be removed if different build settings are needed. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Writing to clipboard with DataWriterItem Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/README.md Shows how to write multiple formats (HTML, plain text, PNG) to the clipboard using DataWriterItem and SystemClipboard.write. Returns early if the clipboard API is unsupported. ```dart import 'package:super_clipboard/super_clipboard.dart'; // ... final clipboard = SystemClipboard.instance; if (clipboard == null) { return; // Clipboard API is not supported on this platform. } final item = DataWriterItem(); item.add(Formats.htmlText('HTML text')); item.add(Formats.plainText('plain text')); item.add(Formats.png(imageData)); await clipboard.write([item]); ``` -------------------------------- ### Configure Flutter Windows project with CMake Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/windows/CMakeLists.txt Project-level CMake configuration for a Flutter Windows application. Sets the binary name, enables modern CMake policies, defines Debug/Profile/Release build modes, applies standard compile settings, and installs runtime files (Flutter assets, ICU data, plugins, and AOT library) into the executable directory. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(SET CMP0063 NEW) 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) 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() set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.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) ``` -------------------------------- ### Application Target and Linking Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Defines the main executable target using the Flutter generated plugin registrant, applies standard build settings, and links against Flutter and GTK libraries. Also adds a dependency on flutter_assemble to ensure the Flutter build runs first. ```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) ``` -------------------------------- ### Declare content provider in AndroidManifest.xml Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/README.md Required to write images and other custom data to the Android clipboard. Replace with your actual package name. ```xml ... ... ``` -------------------------------- ### Include generated plugin build rules Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt Includes the generated_plugins.cmake file which manages building plugins and adding them to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Find GTK+ 3.0 via PkgConfig Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/linux/CMakeLists.txt Finds PkgConfig and checks for the GTK+ 3.0 module, making it available as an imported target. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### CMakeLists.txt: Flutter Linux build configuration Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/flutter/CMakeLists.txt This is the main CMake configuration for a Flutter Linux application. It sets the minimum CMake version, includes the generated configuration, defines a helper function to prepend a prefix to a list, finds system packages (GTK, GLib, GIO), creates the Flutter interface library, and adds a custom command to run the Flutter tool backend. ```cmake # This file controls Flutter-level build steps. It should not be edited. 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) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. # 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() # === 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) # === 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} ) ``` -------------------------------- ### Create and dispose a system-wide hotkey with HotKey.create Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_hot_key/README.md Creates a hotkey for Meta+Alt+Minus that triggers a callback regardless of application focus. Call hotKey.dispose() to unregister the hotkey. Hot keys are registered on physical keys; use super_keyboard_layout to convert between physical and logical keys. ```dart final hotKey = await HotKey.create( definition: HotKeyDefinition( key: PhysicalKeyboardKey.minus, alt: true, meta: true, ), callback: () { print('hot key pressed'); }, ); // .. Meta + Alt + Minus will trigger the callback regardless of whether // the application is in focus // Unregister the hot key hotKey.dispose(); ``` -------------------------------- ### Dragging virtual files with DragItem.addVirtualFile Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/README.md Creates a DragItem and adds a virtual file that generates content on drop. The provider writes multiple lines of UTF-8 encoded text to a sink, then closes it. Supported on iOS, macOS, and Windows. ```dart final item = DragItem(); item.addVirtualFile( format: Formats.plainTextFile, provider: (sinkProvider, progress) { final line = utf8.encode('Line in virtual file\n'); const lines = 10; final sink = sinkProvider(fileSize: line.length * lines); for (var i = 0; i < lines; ++i) { sink.add(line); } sink.close(); }, ); ``` -------------------------------- ### Use KeyboardLayoutManager for key mapping Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/README.md Initialize the KeyboardLayoutManager, listen for layout changes, and map between physical, logical, and platform-specific key codes. The manager.supported check guards against unsupported platforms. ```dart import 'package:super_keyboard_layout/super_keyboard_layout.dart'; void main() async { final manager = await KeyboardLayoutManager.instance(); if (manager.supported) { // Running on supported platform manager.onLayoutChanged.addListener(() { // Keyboard layout changed print('Keyboard layout changed'); }); } final layout = manager.currentLayout; // Getting logical key for physical key 1 with shift for current layout final logicalKey = layout.getLogicalKeyForPhysicalKey(PhysicalKeyboardKey.digit1, shift: true); // Getting physical key for logical key final physicalKey = layout.getPhysicalKeyForLogicalKey(LogicalKeyboardKey.keyA); // Getting platform spcific key code for either logical or physical key final playformCode = layout.getPlatformKeyCode(PhysicalKeyboardKey.digit1); } ``` -------------------------------- ### Project-level CMake configuration Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/windows/CMakeLists.txt Sets CMake minimum version, project name, binary name, and enables modern CMake policy CMP0063. Defines build configuration types and profile build settings. ```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") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Define build configuration option. 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() # Define settings for the Profile build mode. 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}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # 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() # 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) ``` -------------------------------- ### Build type configuration options Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_drag_and_drop/example/linux/CMakeLists.txt This snippet defines the build type configuration. If no build type is set, it defaults to Debug and provides a list of valid build modes: Debug, Profile, and Release. ```cmake # Define build configuration options. 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() ``` -------------------------------- ### Providing lazy representations on demand Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_clipboard/README.md Shows how to provide clipboard data lazily using the .lazy() method. The callbacks must return data quickly; avoid long operations like downloads. On some platforms data may be requested eagerly. ```dart final item = DataWriterItem(); item.add(Formats.htmlText.lazy(() => 'HTML text')); item.add(Formats.plainText.lazy(() => 'plain text')); item.add(Formats.png.lazy(() => imageData)); await clipboard.write([item]); ``` -------------------------------- ### Flutter Windows CMake build configuration Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_context_menu/example/windows/flutter/CMakeLists.txt This CMake file defines the Flutter Windows build configuration. It sets up the Flutter library, wrapper libraries for plugins and the app runner, and a custom command to invoke the Flutter tool backend. It should not be edited; it is generated and controlled by the Flutter tool. ```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") # === 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" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### KeyboardLayoutManager.supported Source: https://github.com/superlistapp/super_native_extensions/blob/main/super_keyboard_layout/README.md A boolean property indicating whether the current platform is supported. ```APIDOC ## KeyboardLayoutManager.supported ### Description Indicates whether the current platform is supported by the plugin. ### Property supported (bool) ### Example ```dart if (manager.supported) { // Running on supported platform } ``` ```