### Run Flutter Barcode SDK Example Application Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/README.md This Bash command is used to launch the Flutter Barcode SDK example application. Execute this command in your terminal from the project's root directory after configuring the license key to run the app on a connected device or emulator. ```bash flutter run ``` -------------------------------- ### Configure Dynamsoft License Key in Flutter Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/README.md This Dart code snippet demonstrates how to set the trial license key obtained from Dynamsoft within the 'example/lib/license.dart' file. Replace the placeholder 'LICENSE-KEY' with your actual license string to enable the SDK's functionality. ```dart String LICENSE_KEY = 'LICENSE-KEY'; ``` -------------------------------- ### Install Application Binary and Core Flutter Files Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This section defines the installation rules for the application's runtime components. It installs the main application binary, Flutter's ICU data file, and the core Flutter library to their respective destination directories. It also conditionally installs any bundled plugin libraries if they exist, ensuring all necessary runtime dependencies are placed correctly for execution. ```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) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Configure Installation Paths and Defaults Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This block configures the installation process for the application. It sets the build bundle directory to the target file's location and ensures that Visual Studio includes the install step by default. If the `CMAKE_INSTALL_PREFIX` is not already set, it defaults it to the build bundle directory. It also defines subdirectories for installed data and libraries. ```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 Flutter Assets and AOT Library Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This code manages the installation of Flutter assets and the Ahead-Of-Time (AOT) compiled library. It first ensures that any stale asset directories are removed before copying the current build's assets. The AOT library is conditionally installed only for Profile and Release builds, optimizing performance for production environments. ```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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Configure Application Installation and Bundling Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Sets up the installation prefix for creating a relocatable application bundle in the build directory. It includes steps to clean the bundle directory, define installation destinations for data and libraries, and install the executable, ICU data, Flutter library, and bundled plugin libraries. This ensures all necessary components are packaged for deployment. ```CMake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### Run Flutter Barcode Scanner on Windows and Linux Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md These commands navigate to the example directory and run the Flutter application specifically targeting Windows or Linux desktop environments, enabling barcode reading and scanning functionalities. ```bash cd example # Windows flutter run -d windows # Linux flutter run -d linux ``` -------------------------------- ### Run Flutter Barcode Scanner on Web (Chrome) Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md This command navigates to the example directory and launches the Flutter application in Chrome, demonstrating web-based barcode scanning capabilities. ```bash cd example flutter run -d chrome ``` -------------------------------- ### Run Flutter Barcode Scanner on Android/iOS Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md This command navigates to the example directory and runs the Flutter application, demonstrating barcode reading from image files and camera streams on Android and iOS devices. ```bash cd example flutter run ``` -------------------------------- ### Define CMake Project and Binary Name Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This section sets the minimum required CMake version, defines the project name and its supported languages (CXX), and specifies the output binary name for the application. It also explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```CMake cmake_minimum_required(VERSION 3.14) project(flutter_barcode_sdk_example LANGUAGES CXX) set(BINARY_NAME "flutter_barcode_sdk_example") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This line adds preprocessor definitions to enable Unicode support across all projects compiled with this CMake configuration. This ensures proper handling of wide characters in the application. ```CMake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### CMake Build Configuration for Flutter Barcode SDK Plugin Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/linux/CMakeLists.txt This CMakeLists.txt file defines the build process for the `flutter_barcode_sdk` Flutter plugin. It sets up project properties, defines the shared library, specifies compile definitions, includes directories, links necessary libraries (Flutter, DynamsoftCore, DynamsoftLicense, DynamsoftCaptureVisionRouter, DynamsoftUtility, GTK), and configures installation paths for bundled resources. ```CMake cmake_minimum_required(VERSION 3.10) set(PROJECT_NAME "flutter_barcode_sdk") project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed set(PLUGIN_NAME "flutter_barcode_sdk_plugin") link_directories("${PROJECT_SOURCE_DIR}/lib/") add_library(${PLUGIN_NAME} SHARED "flutter_barcode_sdk_plugin.cc" ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter DynamsoftCore DynamsoftLicense DynamsoftCaptureVisionRouter DynamsoftUtility) target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) set_target_properties(${PLUGIN_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN" ) # List of absolute paths to libraries that should be bundled with the plugin set(flutter_barcode_sdk_bundled_libraries "" PARENT_SCOPE ) install(DIRECTORY "${PROJECT_SOURCE_DIR}/../linux/lib/" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" ) install(DIRECTORY "${PROJECT_SOURCE_DIR}/../resources/Templates" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/" ) ``` -------------------------------- ### CMake Script for Flutter Asset and AOT Library Installation Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt This CMake script defines the installation rules for Flutter assets and the AOT (Ahead-Of-Time) compiled library. It first sets the directory name for Flutter assets, then removes any existing assets before installing the new ones. Additionally, it conditionally installs the AOT library only for non-Debug builds, optimizing the final application size and performance. ```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 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() ``` -------------------------------- ### Include Flutter Build Rules and Plugins Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This section integrates Flutter's build system into the native project. It sets the path to the Flutter managed directory, includes its build rules via `add_subdirectory`, and incorporates the application's 'runner' subdirectory. Additionally, it includes generated plugin build rules, ensuring all Flutter native components and plugins are properly linked. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Define Standard Compilation Settings Function Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This CMake function, `APPLY_STANDARD_SETTINGS`, defines a set of common compilation options to be applied to a specified target. These options include setting the C++ standard to C++17, configuring warning levels, enabling exception handling, and defining `_DEBUG` for Debug configurations. It's designed for reuse across multiple targets. ```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() ``` -------------------------------- ### Configure Build Modes (Debug, Profile, Release) Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/CMakeLists.txt This code block configures different build types (Debug, Profile, Release) for the project. It checks if the generator supports multi-configuration and sets `CMAKE_CONFIGURATION_TYPES` accordingly. If not, it defaults to 'Debug' and allows selection from 'Debug', 'Profile', 'Release'. It also ensures that Profile build flags mirror Release flags for consistent optimization. ```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() 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}") ``` -------------------------------- ### CMake Minimum Version and Ephemeral Directory Setup Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Sets the minimum required CMake version to 3.14 and defines the 'EPHEMERAL_DIR' variable, which points to a directory containing generated build configurations and temporary files for the Flutter build process. ```CMake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Define Flutter Library and Build Paths Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Sets various CMake variables that define paths to key Flutter build artifacts and directories. These include the main Flutter library (`libflutter_linux_gtk.so`), the ICU data file, the project's build directory, and the AOT (Ahead-Of-Time) compiled application library. These variables are published to the parent scope for use in subsequent build and installation steps. ```CMake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### Flutter Barcode SDK API Reference Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md Detailed API methods for the Flutter Barcode SDK, including functions for setting licenses, initializing the reader, decoding from files and buffers, and managing parameters. This section outlines the method signatures, descriptions, parameters, and return types for each API call. ```APIDOC Method: setLicense Signature: Future setLicense(String license) Description: Sets the Dynamsoft Barcode Reader license key. Parameters: license: The license key string. Return Type: Future Method: init Signature: Future init() Description: Initializes the barcode reader and applies default parameters for the current platform. Parameters: None Return Type: Future Method: decodeFile Signature: Future> decodeFile(String filename) Description: Decodes barcodes from an image file. Parameters: filename: Path to the image file. Return Type: Future> Method: decodeImageBuffer Signature: Future> decodeImageBuffer(Uint8List bytes, int width, int height, int stride, int format, int rotation) Description: Decodes barcodes from a raw image buffer (for real-time or camera preview scanning). Parameters: bytes: Image buffer (raw bytes) width: Image width height: Image height stride: Bytes per row format: Pixel format (see ImagePixelFormat) rotation: 0/90/180/270 Return Type: Future> Method: setBarcodeFormats Signature: Future setBarcodeFormats(int formats) Description: Sets the barcode formats to be detected. Parameters: formats: Bitwise combination of barcode formats (see BarcodeFormat). Return Type: Future Method: getParameters Signature: Future getParameters() Description: Retrieves the current barcode detection settings as a JSON string. Parameters: None Return Type: Future Method: setParameters Signature: Future setParameters(String params) Description: Updates barcode detection parameters with a JSON string. Parameters: params: JSON string of detection parameters. Return Type: Future ``` -------------------------------- ### Configure Flutter Library and Application Target Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Includes Flutter's managed directory for build rules, finds system dependencies like GTK using PkgConfig, defines the application executable with its source files, and applies the previously defined standard build settings. This section integrates the Flutter framework and external libraries into the application build. ```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}") add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Configure Flutter Desktop Application Runner with CMake Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/runner/CMakeLists.txt This snippet defines the CMake build configuration for a Flutter desktop application's runner executable. It specifies the source files, applies standard build settings, injects Flutter version information as preprocessor definitions, disables specific Windows macros to prevent conflicts, links required libraries like 'flutter', 'flutter_wrapper_app', and 'dwmapi.lib', and ensures the Flutter tool's build steps are executed. ```CMake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Find and Check System Dependencies (GTK, GLIB, GIO) Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Locates and verifies the presence of essential system-level libraries required for Flutter's Linux/GTK integration. It uses `find_package` for PkgConfig and `pkg_check_modules` to ensure GTK+-3.0, GLIB-2.0, and GIO-2.0 are available as imported targets. ```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) ``` -------------------------------- ### C++ Wrapper Source File Lists Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Organizes C++ source files for the client wrapper into distinct lists: 'CPP_WRAPPER_SOURCES_CORE' for core implementations, 'CPP_WRAPPER_SOURCES_PLUGIN' for plugin-specific code, and 'CPP_WRAPPER_SOURCES_APP' for application-specific code. Each list's paths are then prefixed with 'WRAPPER_ROOT'. ```CMake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Include Generated Configuration and Wrapper Root Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Includes a CMake configuration file ('generated_config.cmake') provided by the Flutter tool and defines 'WRAPPER_ROOT' to specify the location of the C++ client wrapper sources. ```CMake include(${EPHEMERAL_DIR}/generated_config.cmake) set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Configure Flutter Library Headers and Linking Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Manages the inclusion of Flutter library header files and configures the `flutter` CMake INTERFACE library. It appends a comprehensive list of Flutter header files, then uses the custom `list_prepend` function to add the ephemeral directory path to each. Finally, it defines the `flutter` library, specifies its include directories, and links it against the main Flutter library and required system dependencies (GTK, GLIB, GIO), establishing a dependency on the `flutter_assemble` target. ```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 ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Set CMake Policy and Runtime Path Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Enables modern CMake behaviors by setting policy CMP0063 to NEW, which avoids warnings with recent CMake versions. It also configures the runtime path (`CMAKE_INSTALL_RPATH`) to load bundled libraries from the 'lib' directory relative to the executable, ensuring dependencies are found at runtime. ```CMake cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Configure CMake Project and Application Binary Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Sets the minimum required CMake version, defines the project name, and configures the executable's name and application ID for the Flutter application. These settings are fundamental for project identification and build output. ```CMake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "flutter_barcode_sdk_example") set(APPLICATION_ID "com.example.flutter_barcode_sdk_example") ``` -------------------------------- ### Flutter Plugin Wrapper Library Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Creates a static library named 'flutter_wrapper_plugin' from the core and plugin-specific C++ wrapper sources. It configures properties like position-independent code and symbol visibility, links against the 'flutter' library, and includes necessary wrapper headers, establishing a dependency on 'flutter_assemble'. ```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) ``` -------------------------------- ### Flutter Application Wrapper Library Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Defines a static library 'flutter_wrapper_app' using core and application-specific C++ wrapper sources. It applies standard build settings, links to the 'flutter' library, and includes wrapper headers, ensuring proper compilation and linking for the Flutter application runner. ```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) ``` -------------------------------- ### Flutter Tool Backend Custom Build Command and Target Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Configures a custom CMake command and target (`flutter_assemble`) responsible for invoking the Flutter tool backend script. This command generates the Flutter library and headers. It is designed to run every time due to a `_phony_` output file, ensuring artifacts are always up-to-date. The command executes an environment-wrapped script, passing the target platform and build type. ```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} ) ``` -------------------------------- ### Include Dynamsoft Capture Vision Bundle for Web Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md This HTML snippet integrates the Dynamsoft Capture Vision JavaScript bundle into the `index.html` file for web applications. It provides the necessary client-side libraries for barcode decoding functionality in a web environment, ensuring the SDK's features are available in the browser. ```HTML ``` -------------------------------- ### Configure Flutter Barcode SDK C++ Plugin with CMake Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/windows/CMakeLists.txt This CMake script defines the build process for the 'flutter_barcode_sdk_plugin' shared library. It sets project properties, specifies source files ('flutter_barcode_sdk_plugin.cpp'), includes directories, and links essential Flutter and Dynamsoft libraries. It also defines paths for resources to be bundled with the plugin. ```CMake cmake_minimum_required(VERSION 3.15) set(PROJECT_NAME "flutter_barcode_sdk") project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed set(PLUGIN_NAME "flutter_barcode_sdk_plugin") link_directories("${PROJECT_SOURCE_DIR}/lib/") add_library(${PLUGIN_NAME} SHARED "flutter_barcode_sdk_plugin.cpp" ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_options(${PLUGIN_NAME} PRIVATE /wd4121 /W3 /WX-) target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin DynamsoftCorex64 DynamsoftLicensex64 DynamsoftCaptureVisionRouterx64 DynamsoftUtilityx64) # List of absolute paths to libraries that should be bundled with the plugin set(flutter_barcode_sdk_bundled_libraries "${PROJECT_SOURCE_DIR}/bin/" "${PROJECT_SOURCE_DIR}/../resources/Templates" PARENT_SCOPE ) ``` -------------------------------- ### Set CMake Minimum Version and Ephemeral Directory Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Initializes the CMake project by setting the minimum required CMake version to 3.10 and defining the `EPHEMERAL_DIR` variable. This directory is used for storing generated build artifacts and includes a configuration file provided by the Flutter tool. ```CMake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command named 'flutter_assemble' that invokes the Flutter tool's backend script. This command is designed to run every time (using a phony output) to ensure that critical build artifacts, such as the Flutter library and C++ wrapper sources, are generated or updated. ```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 ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Include Generated Flutter Plugins Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Includes the CMake file responsible for building and integrating generated Flutter plugins into the application. This ensures that any Flutter plugins used in the project are correctly compiled and linked. ```CMake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Configure System Root for Cross-Building Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Sets up the CMake system root (`CMAKE_SYSROOT`) and defines find root path modes when `FLUTTER_TARGET_PLATFORM_SYSROOT` is specified. This configuration is crucial for cross-compilation, directing CMake to search for programs, packages, libraries, and includes within the specified sysroot. ```CMake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Set Runtime Output Directory for Executable Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Configures the runtime output directory for the application executable to a subdirectory (`intermediates_do_not_run`). This prevents users from attempting to run the unbundled binary directly, as it requires resources to be in specific relative locations within the final application bundle. ```CMake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Fallback Flutter Target Platform Configuration Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Ensures that 'FLUTTER_TARGET_PLATFORM' is defined, setting a default to 'windows-x64' if it's not already specified. This provides compatibility for older versions of the Flutter tool. ```CMake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Configure Android Minimum SDK Version Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md This snippet specifies the minimum Android SDK version required for the application. It should be placed within the `android/app/build.gradle` file to ensure compatibility with the target Android versions. ```YAML minSdkVersion 21 ``` -------------------------------- ### Flutter Library Headers and Interface Target Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Lists essential Flutter library headers, transforms their paths to include the ephemeral directory, and defines an 'INTERFACE' library target named 'flutter'. This target specifies include directories and links against the Flutter library, establishing a dependency on 'flutter_assemble'. ```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}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Link Application Dependencies and Flutter Assemble Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Links the application target with necessary libraries, including Flutter and GTK. It also adds a build dependency on `flutter_assemble`, ensuring that Flutter's build steps (like asset bundling) are completed before the application executable is built. ```CMake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Define Standard Compilation Settings Function Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features (C++14), options (warnings as errors, optimization for non-Debug builds), and definitions (NDEBUG for non-Debug builds) to a specified target. This function promotes consistent build settings across the project. ```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() ``` -------------------------------- ### Open Flutter iOS Project in Xcode Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md This command opens the Xcode workspace for a Flutter project, which is necessary to access and modify the `Assets.xcassets` catalog for customizing the iOS launch screen images. ```Shell open ios/Runner.xcworkspace ``` -------------------------------- ### Add iOS Camera and Microphone Usage Descriptions Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/README.md This XML snippet adds privacy descriptions for camera and microphone usage to the `ios/Runner/Info.plist` file. These descriptions are mandatory for iOS applications that access the device's camera or microphone, ensuring compliance with Apple's privacy guidelines. ```XML NSCameraUsageDescription Can I use the camera please? NSMicrophoneUsageDescription Can I use the mic please? ``` -------------------------------- ### Flutter Library and Path Definitions Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/windows/flutter/CMakeLists.txt Defines key paths and library names for the Flutter build, such as the main Flutter DLL, ICU data file, project build directory, and AOT library. These variables are set with 'PARENT_SCOPE' to be accessible in parent CMake contexts. ```CMake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Define CMake Build Type Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/CMakeLists.txt Configures the default CMake build type to 'Debug' if it's not already set. This allows developers to choose between 'Debug', 'Profile', and 'Release' modes, influencing compilation flags and optimization levels. ```CMake if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### CMake Function to Prepend to List Elements Source: https://github.com/yushulx/flutter_barcode_sdk/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake function named `list_prepend`. This function iterates through a given list and prepends a specified prefix to each element, effectively modifying the list in the parent scope. It serves as a workaround for `list(TRANSFORM ... PREPEND ...)` which is not available in CMake 3.10. ```CMake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.