### Build and Run Native Tests for flutter_secure_storage_linux Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Builds the example app to compile the native test binary and then runs the tests using CTest. This process requires starting a keyring daemon first if one is not already running. ```shell # 1. Start a keyring daemon (skip if already running in a desktop session) eval $(dbus-launch --sh-syntax) echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets # 2. Build (compiles the test binary alongside the app) cd flutter_secure_storage/example flutter build linux --debug # 3. Run cd build/linux/x64/debug/plugins/flutter_secure_storage_linux ctest --output-on-failure ``` -------------------------------- ### Install Application and Runtime Files Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Installs the application executable, ICU data, Flutter library, and bundled plugin libraries into the installation bundle. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) 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() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle's installation directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Bundle Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Sets up the installation prefix to create a relocatable bundle and defines directories for data and libraries within the bundle. ```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() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Run Integration Tests Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Navigate to the example directory and execute this command to run integration tests. ```bash flutter drive --target=test_driver/app.dart ``` -------------------------------- ### Install Application Assets Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Installs the application's assets directory into the bundle, ensuring a clean copy on each build. ```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) ``` -------------------------------- ### Install Application Target Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This is a core component of the application's deployment. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Initializes the CMake build system and sets project properties like minimum version, project name, and languages. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) ``` -------------------------------- ### Start GNOME Keyring Daemon for Headless/CI Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Starts a GNOME Keyring daemon with an unlocked keyring for use in headless environments or CI/CD pipelines. This command sets up the D-Bus environment and launches the daemon. ```shell eval $(dbus-launch --sh-syntax) echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets ``` -------------------------------- ### Clean and Rebuild Flutter Project Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Execute these commands to clean the Flutter project, remove old pods, get new dependencies, install pods, and then run the application. This is a troubleshooting step for iOS key lookup issues. ```bash flutter clean rm -Rf ios/Pods flutter pub get cd ios && pod install && cd .. flutter run ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Installs any native libraries associated with bundled plugins into the application bundle's library directory. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install AOT Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for non-Debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install libsecret on Ubuntu/Debian Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Installs the necessary libsecret development and runtime packages for Ubuntu and Debian-based systems. ```shell sudo apt install libsecret-1-0 libsecret-1-dev ``` -------------------------------- ### Install libsecret on Fedora/RHEL/CentOS Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Installs the libsecret package for Fedora, RHEL, and CentOS systems. ```shell sudo dnf install libsecret libsecret-devel ``` -------------------------------- ### Configure Installation Prefix for VS Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Sets the installation prefix to the executable's directory when using Visual Studio, facilitating in-place running. This ensures support files are located correctly. ```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() ``` -------------------------------- ### Migrate with Custom Cipher Algorithms Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure migration with specific key and storage cipher algorithms. This example shows migrating to RSA_ECB_OAEPwithSHA_256andMGF1Padding for keys and AES_GCM_NoPadding for storage, with backup protection enabled. ```dart // Migrating from old to new algorithm with backup protection final storage = FlutterSecureStorage( aOptions: AndroidOptions( migrateWithBackup: true, keyCipherAlgorithm: KeyCipherAlgorithm.RSA_ECB_OAEPwithSHA_256andMGF1Padding, storageCipherAlgorithm: StorageCipherAlgorithm.AES_GCM_NoPadding, ), ); ``` -------------------------------- ### Linux Build Configuration with Snapcraft Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Example snapcraft configuration for building a Flutter project on Linux that requires libsecret. This snippet specifies build-time and run-time packages. ```yaml parts: uet-lms: source: . plugin: flutter flutter-target: lib/main.dart build-packages: - libsecret-1-dev stage-packages: - libsecret-1-0 ``` -------------------------------- ### Define Application Properties Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Sets the binary name and application ID for the Flutter example project. ```cmake set(BINARY_NAME "flutter_secure_storage_example") set(APPLICATION_ID "com.it_nomads.flutter_secure_storage") ``` -------------------------------- ### Find and check system dependencies with PkgConfig Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/flutter/CMakeLists.txt This section uses PkgConfig to find and check for required system libraries such as GTK, GLIB, GIO, BLKID, and LZMA. Ensure these libraries are installed and discoverable by PkgConfig on your system. The `REQUIRED` keyword ensures the build fails if any dependency is not found. ```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) pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) pkg_check_modules(LZMA REQUIRED IMPORTED_TARGET liblzma) ``` -------------------------------- ### Install AOT Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for non-Debug builds (Profile and Release) into the application's data directory. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Enable Native Plugin Tests Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Sets a flag to enable native plugin tests when building the example. ```cmake set(include_flutter_secure_storage_linux_tests TRUE) ``` -------------------------------- ### Install libsecret on Arch-based systems Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Installs the libsecret package, which includes both development and runtime components, on Arch-based Linux distributions. ```shell sudo pacman -S libsecret ``` -------------------------------- ### Install ICU Data File Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Copies native assets provided by the build.dart script into the application bundle's library directory. This ensures all necessary native components are deployed. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Enable Testing Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Enables testing for the project if the include_flutter_secure_storage_windows_tests variable is defined. This is typically set when building the example. ```cmake if (${include_${PROJECT_NAME}_tests}) set(TEST_RUNNER "${PROJECT_NAME}_test") enable_testing() # Add the Google Test dependency. include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/release-1.11.0.zip ) # Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Disable install commands for gtest so it doesn't end up in the bundle. set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) FetchContent_MakeAvailable(googletest) # The plugin's C API is not very useful for unit testing, so build the sources # directly into the test binary rather than using the DLL. add_executable(${TEST_RUNNER} "test/flutter_secure_storage_windows_plugin_test.cpp" ${PLUGIN_SOURCES} ) apply_standard_settings(${TEST_RUNNER}) target_compile_definitions(${TEST_RUNNER} PRIVATE SECURE_STORAGE_KEY_PREFIX="fss_native_test_" FLUTTER_PLUGIN_IMPL ) target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) # flutter_wrapper_plugin has link dependencies on the Flutter DLL. add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FLUTTER_LIBRARY}" $ ) # Enable automatic test discovery. include(GoogleTest) gtest_discover_tests(${TEST_RUNNER}) endif() ``` -------------------------------- ### Configure Flutter library and paths Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/flutter/CMakeLists.txt Sets the paths for the Flutter library, ICU data file, project build directory, and AOT library. These variables are set to be available in the parent scope for use in installation or other build steps. Ensure the `EPHEMERAL_DIR` and `PROJECT_DIR` are correctly defined. ```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) ``` -------------------------------- ### Export Flutter Library and ICU Data Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Exports the Flutter library path and the ICU data file path to the parent scope. This makes them available for installation and other build steps. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Bootstrap Workspace with Melos Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Bootstrap the workspace with melos to prepare the project for development. ```bash melos bootstrap ``` -------------------------------- ### Set Include Directories and Link Libraries Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Configures interface include directories and private library dependencies for the plugin target. Add any plugin-specific dependencies here. ```cmake target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) ``` -------------------------------- ### Add Pub Executables to Path Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Optionally, add the pub executables directory to your PATH environment variable. ```bash export PATH="$PATH":"$HOME/.pub-cache/bin" ``` -------------------------------- ### Fetch Flutter Dependencies Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Run this command in the project directory to fetch Flutter dependencies. ```bash flutter pub get ``` -------------------------------- ### Run Integration Tests for flutter_secure_storage_linux Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Executes integration tests for the flutter_secure_storage_linux plugin on a Linux environment using xvfb-run to simulate a display server. ```shell cd flutter_secure_storage/example xvfb-run flutter test integration_test/linux_test.dart -d linux ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Applies a standard set of build configurations to the executable. This can be customized if the application requires different build settings. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Applies standard build settings configured in the application-level CMakeLists.txt. This can be removed if full control over build settings is desired. ```cmake apply_standard_settings(${PLUGIN_NAME}) ``` -------------------------------- ### Create Secure Storage Instance with Explicit Android Options Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Instantiate the secure storage with custom Android options. ```dart // Or with explicit Android options final storage = FlutterSecureStorage( aOptions: AndroidOptions(), ); ``` -------------------------------- ### Add Flutter and System Dependencies Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Includes the Flutter build rules and finds necessary system libraries like GTK+. ```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}") ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and specifies include directories for the project. Add any application-specific dependencies here. ```cmake 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}") ``` -------------------------------- ### Create Secure Storage Instance with Biometric Support (Graceful Degradation) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Instantiate the secure storage with biometric authentication support, allowing fallback to other authentication methods if biometrics are unavailable. ```dart // Biometric storage with graceful degradation final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( enforceBiometrics: false, // Works without biometrics biometricPromptTitle: 'Authenticate to access data', ), ); ``` -------------------------------- ### Project Configuration Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Sets the project name and specifies CXX as the programming language. The project name is used for build artifacts. ```cmake set(PROJECT_NAME "flutter_secure_storage_windows") project(${PROJECT_NAME} LANGUAGES CXX) ``` -------------------------------- ### Import Flutter Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Import the package to use its functionalities. ```dart import 'package:flutter_secure_storage/flutter_secure_storage.dart'; ``` -------------------------------- ### Custom command to build Flutter library using tool_backend.sh Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/flutter/CMakeLists.txt This custom command invokes the Flutter tool backend script to build the Flutter library and its headers. It uses environment variables and build type information. The `_phony_` target ensures this command runs on every build, as direct input/output tracking for the tool is not available. The output files are `${FLUTTER_LIBRARY}` and `${FLUTTER_LIBRARY_HEADERS}`. ```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 ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Configure Keychain Access Groups (Empty) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_darwin/README.md Add this to your DebugProfile.entitlements and Release.entitlements files for basic Keychain Sharing. Ensure this is configured in both iOS and macOS runner files. ```xml keychain-access-groups ``` -------------------------------- ### Define Application Executable Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Configures the main executable target, linking it with Flutter and GTK libraries, and setting its output directory. ```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) set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Create Default Secure Storage Instance Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Instantiate the secure storage with default options, utilizing RSA OAEP and AES-GCM for Android. ```dart // Default secure storage - Uses RSA OAEP + AES-GCM (recommended) final storage = FlutterSecureStorage(); ``` -------------------------------- ### Add Plugin Source Files Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Appends source files to the PLUGIN_SOURCES list. Any new source files for the plugin should be added here. ```cmake list(APPEND PLUGIN_SOURCES "flutter_secure_storage_windows_plugin.cpp" "flutter_secure_storage_windows_plugin.h" ) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support in the project, ensuring proper handling of international characters. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Migrate to Biometric Storage with Backup Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure migration to biometric-compatible storage while enabling backup protection. `enforceBiometrics` is set to false to allow graceful degradation if biometrics are unavailable. ```dart // Migrating to biometric storage with backup final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( migrateWithBackup: true, enforceBiometrics: false, ), ); ``` -------------------------------- ### Configure Keychain Access Groups with App Group Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_darwin/README.md If your application uses App Groups, include the App Group name prefixed with $(AppIdentifierPrefix) in the `keychain-access-groups` array. This ensures values are correctly written. ```xml keychain-access-groups $(AppIdentifierPrefix)aoeu ``` -------------------------------- ### Copy flutter_windows.dll for Testing Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Configures a custom command to copy flutter_windows.dll next to the test binary after it's built. This ensures the DLL is available for the test runner during discovery and execution. ```cmake add_custom_command(TARGET flutter_secure_storage_windows_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FLUTTER_LIBRARY}" "$" COMMENT "Copying flutter_windows.dll for test runner" ) ``` -------------------------------- ### Snapcraft build configuration for libsecret Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Configures Snapcraft to include libsecret development and runtime packages for building a Flutter application on Linux. ```yaml parts: your-app: plugin: flutter flutter-target: lib/main.dart build-packages: - libsecret-1-dev stage-packages: - libsecret-1-0 ``` -------------------------------- ### Include Generated Plugin Rules Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Includes the CMake script that defines build rules for generated plugins. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define Flutter library headers and create interface library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/flutter/CMakeLists.txt Lists the header files for the Flutter library and creates an interface library target named 'flutter'. This target includes the necessary header directories and links against the Flutter shared library and system dependencies. Ensure all listed headers are present in the specified directory. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 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 PkgConfig::BLKID PkgConfig::LZMA ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Fetch Google Test Dependency Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Fetches the googletest framework from a specific GitHub commit URL. This is essential for setting up the testing environment. ```cmake include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/b514bdc898e2951020cbdca1304b75f5950d1f59.zip DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) # Prevent overriding the parent project's compiler/linker settings on Windows. set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) ``` -------------------------------- ### Create Flutter Wrapper Plugin Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Creates a static library target for the Flutter C++ wrapper intended for plugins. It includes core and plugin-specific sources and links against the main Flutter library. ```cmake 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) ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt A function to apply common compilation settings to a target, including C++ standard, warning levels, and exception handling. ```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() ``` -------------------------------- ### Set Secure Storage Key Prefix Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Defines the SECURE_STORAGE_KEY_PREFIX compile definition. It uses a default value if STORAGE_PREFIX is not defined, otherwise it uses the provided STORAGE_PREFIX. ```cmake if(NOT DEFINED STORAGE_PREFIX) add_compile_definitions(SECURE_STORAGE_KEY_PREFIX="${BINARY_NAME}_VGhpcyBpcyB0aGUgcHJlZml4IGZv_") else() add_compile_definitions(SECURE_STORAGE_KEY_PREFIX="${STORAGE_PREFIX}_VGhpcyBpcyB0aGUgcHJlZml4IGZv_") endif() ``` -------------------------------- ### Define Bundled Libraries Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Defines a list of absolute paths to libraries that should be bundled with the plugin. This can include prebuilt libraries or those from external builds. ```cmake set(flutter_secure_storage_bundled_libraries "" PARENT_SCOPE ) ``` -------------------------------- ### Configure Build Configurations Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) for multi-configuration generators. For single-configuration generators, it sets the default build type if not already defined. ```cmake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt A function to apply common compilation features and options, including C++14 standard, warnings, and optimization levels based on build type. ```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() ``` -------------------------------- ### Flatpak runtime configuration for libsecret Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_linux/README.md Specifies the Freedesktop runtime version required for libsecret support in Flatpak applications. Ensure the runtime version is 25.08 or newer. ```yaml runtime: org.freedesktop.Platform runtime-version: '25.08' # must be 25.08 or newer ``` -------------------------------- ### Set Include Directories Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Adds the parent directory to the include paths for the test executable, allowing it to find necessary header files. ```cmake target_include_directories(flutter_secure_storage_windows_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ) ``` -------------------------------- ### Set C++ Standard Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Specifies that the test executable should be compiled using the C++17 standard. ```cmake target_compile_features(flutter_secure_storage_windows_test PRIVATE cxx_std_17) ``` -------------------------------- ### Configure Build Type Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already configured, allowing for 'Profile' and 'Release' as alternatives. ```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() ``` -------------------------------- ### Create Flutter Wrapper Application Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Creates a static library target for the Flutter C++ wrapper intended for the application runner. It includes core and application-specific sources and links against the main Flutter library. ```cmake 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) ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Defines compilation and linking flags for the Profile build mode, typically mirroring the Release build settings for consistency. ```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}") ``` -------------------------------- ### Set Wrapper Root Directory Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Defines the root directory for the C++ client wrapper sources. This is used to locate necessary C++ files for the Flutter engine. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Define Test Compile Definitions Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Sets compile definitions for the test binary, ensuring it uses the same key prefix as the plugin for consistent testing and includes the FLUTTER_PLUGIN_IMPL macro. ```cmake target_compile_definitions(flutter_secure_storage_windows_test PRIVATE SECURE_STORAGE_KEY_PREFIX="fss_native_test_" FLUTTER_PLUGIN_IMPL ) ``` -------------------------------- ### Create Secure Storage Instance with Strict Biometric Enforcement Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Instantiate the secure storage with strict biometric authentication enforcement, requiring device security measures like biometrics, PIN, or pattern. ```dart // Strict biometric enforcement (requires device security) final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( enforceBiometrics: true, // Requires biometric/PIN/pattern biometricPromptTitle: 'Authentication Required', ), ); ``` -------------------------------- ### Define C++ Wrapper Plugin Sources Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Appends C++ source files related to plugin registration for the client wrapper. These are used when building Flutter plugins. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Define C++ Wrapper Core Sources Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Appends core C++ source files for the client wrapper to a list. These files contain fundamental implementations for Flutter integration. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### CMake Policy Opt-in Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Explicitly opts into modern CMake behaviors to prevent warnings with recent CMake versions. Ensures compatibility and adherence to current standards. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Link Libraries for Test Executable Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Links the test executable against the flutter_wrapper_plugin and the Google Test main library, providing necessary functionalities for testing. ```cmake target_link_libraries(flutter_secure_storage_windows_test PRIVATE flutter_wrapper_plugin GTest::gtest_main ) ``` -------------------------------- ### Activate Melos Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Activate the melos tool globally using dart pub global activate. ```bash dart pub global activate melos ``` -------------------------------- ### Write Data to Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Write a key-value pair to the secure storage. Ensure the storage instance is initialized. ```dart await storage.write(key: 'username', value: 'flutter_user'); ``` -------------------------------- ### Enable Crash-Resistant Migration with Backup Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Enable crash-resistant migration by setting `migrateWithBackup` to true in `AndroidOptions`. This protects against data loss during encryption algorithm upgrades. ```dart final storage = FlutterSecureStorage( aOptions: AndroidOptions( migrateWithBackup: true, // Enable crash-resistant migration ), ); ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Includes a CMake configuration file generated by the Flutter tool. This file provides project-specific settings and configurations. ```cmake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Configure Keychain Access Groups for macOS and iOS Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Add this XML to your entitlement files to configure keychain access groups. If using App Groups, include the App Group name prefixed with $(AppIdentifierPrefix). ```xml keychain-access-groups ``` ```xml keychain-access-groups $(AppIdentifierPrefix)aoeu ``` -------------------------------- ### Define Executable Target Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Defines the main executable for the Windows runner. Source files and resources are listed here. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` compatibility. ```cmake 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" ) ``` -------------------------------- ### Discover Tests with Google Test Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Enables Google Test to discover tests using the PRE_TEST mode. This defers test case discovery to the ctest runtime, ensuring flutter_windows.dll is present when the binary is first executed. ```cmake include(GoogleTest) # PRE_TEST defers test-case discovery to ctest runtime (not cmake build time), # so flutter_windows.dll is already present when the binary is first executed. gtest_discover_tests(flutter_secure_storage_windows_test DISCOVERY_MODE PRE_TEST ) ``` -------------------------------- ### Add Flutter Build Dependencies Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Ensures that the Flutter build process, specifically `flutter_assemble`, is run as a dependency before the main executable is built. This is a required step for Flutter projects. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Add Flutter Version Preprocessor Definitions Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Sets preprocessor definitions for the build version, including major, minor, patch, and build numbers. These are useful for embedding version information directly into the compiled code. ```cmake 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}") ``` -------------------------------- ### Define C++ Wrapper Application Sources Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Appends C++ source files for the Flutter application runner. These files are used for integrating Flutter into a native Windows application. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Define list_prepend function in CMake Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/linux/flutter/CMakeLists.txt This function prepends a prefix to each element in a given list. It is used as a workaround for older CMake versions (pre-3.10) that do not support `list(TRANSFORM ... PREPEND ...)`. Ensure the list name and prefix are correctly provided. ```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() ``` -------------------------------- ### Define Plugin Library Target Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Defines the plugin as a SHARED library. The target name must match PLUGIN_NAME. ```cmake add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SOURCES} ) ``` -------------------------------- ### Compile Test Executable Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/test/CMakeLists.txt Compiles the test executable, directly including the plugin's C++ source files. This makes C++ class symbols available without requiring DLL exports. ```cmake add_executable(flutter_secure_storage_windows_test flutter_secure_storage_windows_plugin_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../flutter_secure_storage_windows_plugin.cpp ) ``` -------------------------------- ### Web Options for Application-Specific Key Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Flutter Secure Storage on the web with an application-specific key and IV for enhanced security. This wraps the key stored in LocalStorage. ```dart final _storage = const FlutterSecureStorage( webOptions: WebOptions( wrapKey: '${your_application_specific_key}', wrapKeyIv: '${your_application_specific_iv}', ), ); ``` -------------------------------- ### Plugin Name Definition Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Defines the name of the plugin library. This name must not be changed as it's used during the build process. ```cmake set(PLUGIN_NAME "flutter_secure_storage_windows_plugin") ``` -------------------------------- ### Define Flutter Tool Backend Custom Command Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command generates necessary Flutter build artifacts like DLLs and headers. ```cmake 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 ) ``` -------------------------------- ### Export Project Build Directory and AOT Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Exports the project's build directory and the Ahead-Of-Time (AOT) compiled library path to the parent scope. These are used for linking and deployment. ```cmake set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Set Executable Name Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/CMakeLists.txt Defines the on-disk name for the application executable. This can be modified to change the application's name. ```cmake set(BINARY_NAME "flutter_secure_storage_example") ``` -------------------------------- ### Create Flutter Interface Library Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Defines an INTERFACE library target named 'flutter'. This target is used to manage include directories and link against the Flutter library. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Set Flutter Library Path Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Defines the path to the Flutter Windows DLL. This library is essential for running Flutter applications on Windows. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") ``` -------------------------------- ### Enable Secure Enclave for iOS and macOS Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Use this snippet to write data with Secure Enclave protection and access control flags for user presence verification. This applies to both iOS and macOS options. ```dart final storage = FlutterSecureStorage(); await storage.write( key: 'token', value: 'secret', iOptions: IOSOptions( useSecureEnclave: true, accessControlFlags: const [ AccessControlFlag.userPresence, // require Face ID/Touch ID or passcode ], ), mOptions: MacOsOptions( useSecureEnclave: true, accessControlFlags: const [AccessControlFlag.userPresence], ), ); ``` -------------------------------- ### Check for Key Existence in Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Check if a specific key exists in the secure storage. ```dart bool containsKey = await storage.containsKey(key: 'username'); ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Add the flutter_secure_storage package to your project's pubspec.yaml file. ```yaml dependencies: flutter_secure_storage: ^ ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Specifies the minimum required version of CMake for this project. This ensures compatibility with necessary CMake features. ```cmake cmake_minimum_required(VERSION 3.14) ``` -------------------------------- ### macOS/iOS Keychain Sharing Configuration Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Keychain Sharing for macOS and iOS by adding the 'keychain-access-groups' key to your entitlement files. This is crucial for values to be written correctly. ```xml keychain-access-groups ``` -------------------------------- ### Create Flutter Assemble Custom Target Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the output of the Flutter tool backend command. This ensures that Flutter build artifacts are generated before other targets that depend on them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Android Manifest Permissions for Biometrics Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Add these permissions to your AndroidManifest.xml to enable biometric authentication. USE_BIOMETRIC is recommended for API 28+, while USE_FINGERPRINT is for backward compatibility on older versions. ```xml ``` ```xml ``` -------------------------------- ### Define Flutter Library Headers Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Appends a list of Flutter library header files to a variable. These headers are necessary for interacting with the Flutter engine. ```cmake 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}/") ``` -------------------------------- ### Define Ephemeral Directory Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Sets a variable for the ephemeral build directory, which is used for generated build files. This path is relative to the current source directory. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Android Default Encryption Options Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Use the default AndroidOptions for secure storage, which employs RSA OAEP for key wrapping and AES GCM for storage encryption. This provides strong authenticated encryption without biometric support. ```dart final options = AndroidOptions(); await storage.write(key: key, value: value, aOptions: options); ``` -------------------------------- ### Read Data from Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Read the value associated with a given key from the secure storage. The returned value can be null if the key does not exist. ```dart String? username = await storage.read(key: 'username'); ``` -------------------------------- ### Disable Android Auto Backup Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configures the AndroidManifest.xml to disable auto backup for the application. This is recommended to prevent potential 'InvalidKeyException' errors. ```xml ``` -------------------------------- ### Delete All Data from Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Delete all key-value pairs stored by the application using this package. ```dart await storage.deleteAll(); ``` -------------------------------- ### Set Target Properties for Visibility Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage_windows/windows/CMakeLists.txt Sets C++ visibility to hidden by default to reduce symbol conflicts. Explicitly exported symbols should use the FLUTTER_PLUGIN_EXPORT macro. ```cmake set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) ``` -------------------------------- ### macOS/iOS App Group Keychain Sharing Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Keychain Sharing for macOS and iOS when using App Groups. Add the App Group name to the 'keychain-access-groups' argument in your entitlement files. ```xml keychain-access-groups $(AppIdentifierPrefix)aoeu ``` -------------------------------- ### Android Optional Biometric Encryption Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Configure Android secure storage to optionally use biometric authentication. If biometrics are unavailable, it gracefully degrades. KeyStore is used for key management. ```dart final options = AndroidOptions.biometric(enforceBiometrics: false); await storage.write(key: key, value: value, aOptions: options); ``` -------------------------------- ### Set Fallback Target Platform Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/flutter/CMakeLists.txt Sets a fallback value for FLUTTER_TARGET_PLATFORM if it's not already defined. This ensures a default platform is used for older Flutter tool versions. ```cmake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Optional Biometric Authentication (Android) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Flutter Secure Storage for optional biometric authentication on Android. This allows graceful degradation if biometrics are not available or enforced. ```dart final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( enforceBiometrics: false, // Default - works without biometrics biometricPromptTitle: 'Unlock to access your data', biometricPromptSubtitle: 'Use fingerprint or face unlock', ), ); ``` -------------------------------- ### Configure iOS Keychain Accessibility Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Sets the accessibility option for iOS Keychain to 'first_unlock'. This controls when secure values can be accessed after the device is unlocked. ```dart final options = IOSOptions(accessibility: KeychainAccessibility.first_unlock); await storage.write(key: key, value: value, iOptions: options); ``` -------------------------------- ### Delete Data from Secure Storage Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Delete a specific key-value pair from the secure storage. ```dart await storage.delete(key: 'username'); ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/example/windows/runner/CMakeLists.txt Disables Windows-specific macros like NOMINMAX that can conflict with standard C++ library functions, preventing potential compilation errors. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` -------------------------------- ### Android Strong Biometric Only Encryption Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Configure Android secure storage to require only strong (Class 3) biometrics for authentication, rejecting device credentials like PINs or patterns. Requires API level 28+. ```dart final options = AndroidOptions.biometric(enforceBiometrics: true, biometricType: AndroidBiometricType.strongBiometricOnly); await storage.write(key: key, value: value, aOptions: options); ``` -------------------------------- ### Strong Biometric Only (Android) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Flutter Secure Storage to only accept strong biometric authentication on Android, rejecting device credentials like PIN or pattern. This requires API Level 11.0 (API 30) minimum for full enforcement. ```dart final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( enforceBiometrics: true, biometricType: AndroidBiometricType.strongBiometricOnly, biometricPromptTitle: 'Fingerprint required', ), ); ``` -------------------------------- ### Strict Biometric Enforcement (Android) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Configure Flutter Secure Storage for strict biometric authentication on Android, requiring device security enrollment. The app will throw an exception if no PIN, pattern, password, or biometric is enrolled. ```dart final storage = FlutterSecureStorage( aOptions: AndroidOptions.biometric( enforceBiometrics: true, // Requires biometric/PIN/pattern biometricPromptTitle: 'Biometric authentication required', ), ); ``` -------------------------------- ### Android Required Biometric Encryption Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md Configure Android secure storage to strictly require biometric or PIN authentication. This configuration enforces device security and requires API level 28 or higher. ```dart final options = AndroidOptions.biometric(enforceBiometrics: true); await storage.write(key: key, value: value, aOptions: options); ``` -------------------------------- ### Disable Automatic Migration (Android) Source: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/flutter_secure_storage/README.md Disable the automatic migration of data from older cipher algorithms to newer ones in Flutter Secure Storage for Android. This is enabled by default. ```dart final storage = FlutterSecureStorage( aOptions: AndroidOptions( migrateOnAlgorithmChange: false, ), ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.