### Navigate to Example Directory Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_ui/example/README.md Change the current directory to the example folder. This is a prerequisite for running the example. ```bash cd example ``` -------------------------------- ### Installation Bundle Directory Setup Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/linux/CMakeLists.txt Configures the installation prefix and bundle directories, ensuring a clean build bundle directory on each run. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. 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") ``` -------------------------------- ### Installation Bundle Directory Setup Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Configures the installation prefix to be a bundle directory within the build directory. This ensures that the installation creates a self-contained application bundle. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Get Project Dependencies Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_ui/example/README.md Download and install the necessary packages for the Flutter project. This command should be run after navigating to the example directory. ```bash flutter pub get ``` -------------------------------- ### Run Flutter Example Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_ui/example/README.md Execute the Flutter example application on a connected device or emulator. Ensure all dependencies are fetched before running. ```bash flutter run ``` -------------------------------- ### Configure Installation Directory and Rules Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_backend/example/windows/CMakeLists.txt Sets up installation directories and rules for the application executable, data files, libraries, and assets. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Installs the main Flutter library file to the installation's library directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Directory Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/CMakeLists.txt Sets up installation paths, ensuring support files are placed next to the executable for in-place execution. Configures the installation prefix to be the bundle directory and defines data and library directories. ```cmake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(DART_FFI_DIR "${CMAKE_INSTALL_PREFIX}") set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Installs any bundled plugin libraries to the lib directory within the bundle. This loop iterates through a list of plugin libraries and installs each one. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Application Executable Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This is a core step for deploying the application. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Prefix and Bundle Directory Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Sets up the installation prefix and the directory for the relocatable bundle, ensuring a clean build directory. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Installation Directories Definition Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Defines the destination directories for data and libraries within the installation bundle. These paths are used to organize the installed application files. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Define Installation Directories Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Sets variables for installation directories, including library, data, and FFI DLL locations within the bundle. ```cmake set(DART_FFI_DIR "${CMAKE_INSTALL_PREFIX}/lib") set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Installs any bundled plugin libraries to the library directory within the application bundle. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Application Executable and Data Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/linux/CMakeLists.txt Installs the application executable, ICU data, and Flutter library to the specified bundle directories. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Prefix for Bundled Files Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Sets the installation prefix to be adjacent to the executable, facilitating in-place running and Visual Studio integration. This ensures support files are correctly located. ```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 cargo-ndk Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/android/README.md Use this command to install the cargo-ndk tool, which is required for building Rust projects for Android. ```bash cargo install cargo-ndk ``` -------------------------------- ### Install AOT Library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for non-Debug builds. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Rust Main Function Example Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/rust-lib/flowy-document/tests/assets/html/notion.html A basic Rust program that prints 'Hello World!' to the console. This is a standard entry point for Rust applications. ```rust // This is the main function. fn main() { // Print text to the console. **println**!("Hello World!"); } ``` -------------------------------- ### Install Application Executable and Core Files Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Installs the main application executable, Flutter ICU data, Dart FFI DLL, and the Flutter library to their respective destinations within the bundle. ```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 "${DART_FFI_DLL}" DESTINATION "${DART_FFI_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Rust Hello World Program Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/rust-lib/flowy-document/tests/assets/text/plain_text.txt A basic Rust program that prints 'Hello World!' to the console. This is a common starting point for learning Rust. ```rust // This is the main function. fn main() { // Print text to the console. **println**!("Hello World!"); } ``` -------------------------------- ### Install AOT Library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library. This is only done for Profile and Release build configurations to optimize performance. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### AppFlowy CMake Project Setup Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/linux/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and binary name. It also configures application ID and build policies. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "flowy_infra_ui_example") set(APPLICATION_ID "com.example.flowy_infra_ui") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Installs the Flutter assets directory, ensuring it's up-to-date by removing the old one before copying the new one. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AppFlowy Executable and Support Files Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/CMakeLists.txt Installs the main AppFlowy executable, ICU data, Dart FFI DLL, Flutter library, and any bundled plugin libraries to their respective destinations. Ensures runtime components are correctly placed. ```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 "${DART_FFI_DLL}" DESTINATION "${DART_FFI_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() ``` -------------------------------- ### Initialize CMake and Set Directories Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/flutter/CMakeLists.txt Sets the minimum CMake version and defines the ephemeral directory for generated configuration files. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Library Installation Path Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Configures the runtime search path for bundled libraries to be relative to the executable. This is crucial for ensuring the application can find its dynamic libraries after installation. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install AOT Library for Release Builds Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, but only for Profile and Release configurations. This optimizes performance for non-debug builds. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/CMakeLists.txt Specifies the minimum required CMake version and names the project. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Define Flutter library path Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt Sets the path to the Flutter Windows DLL. This is published to the parent scope for use in the install step. ```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) ``` -------------------------------- ### AppFlowy Project Configuration Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/android/app/src/main/CMakeLists.txt Sets the minimum required CMake version and defines the project name for AppFlowy. Logs the NDK path and indicates the start of library copying. ```cmake cmake_minimum_required(VERSION 3.10.0) project(AppFlowy) message(CONFIGURE_LOG "NDK PATH: ${ANDROID_NDK}") message(CONFIGURE_LOG "Copying libc++_shared.so") ``` -------------------------------- ### Get Available AI Models in Dart Source: https://context7.com/appflowy-io/appflowy/llms.txt Fetches a list of available AI models supported by the service. Iterates through the response to print model names, providers, and capabilities. ```dart // Get AI models available Future getAvailableModels() async { final result = await AIEventGetAvailableModels().send(); result.fold( (models) { for (final model in models.items) { print('Model: ${model.name}'); print(' Provider: ${model.provider}'); print(' Capabilities: ${model.capabilities}'); } }, (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Get All Appflowy Workspaces Source: https://context7.com/appflowy-io/appflowy/llms.txt Fetches all workspaces associated with the current user. It iterates through the workspaces and prints their names, IDs, creation timestamps, and member counts. Handles potential errors during the fetch operation. ```dart // Get all workspaces for current user Future getAllWorkspaces() async { final result = await UserEventGetAllWorkspace().send(); result.fold( (workspaces) { for (final workspace in workspaces.items) { print('Workspace: ${workspace.name} (${workspace.workspaceId})'); print(' Created: ${workspace.createdAtTimestamp}'); print(' Member count: ${workspace.memberCount}'); } }, (error) => print('Error fetching workspaces: ${error.msg}'), ); } ``` -------------------------------- ### System Dependencies and Application Build Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/linux/CMakeLists.txt Finds PkgConfig and GTK, defines the application ID, and sets up the main executable target with source files and linked libraries. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Application build 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) ``` -------------------------------- ### Install AOT Library Conditionally (CMake) Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Installs the AOT library only on non-Debug builds. Ensure CMAKE_BUILD_TYPE is set appropriately. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Rust Main Function - Hello World Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/rust-lib/flowy-document/tests/assets/html/code.html This is the main entry point of the Rust program. It prints 'Hello World!' to the console. ```rust // This is the main function. fn main() { // Print text to the console. println!("Hello World!"); } ``` -------------------------------- ### Find and Link System Libraries Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/flutter/CMakeLists.txt Uses `pkg-config` to find and check for required system libraries: GTK, GLIB, and GIO. It then makes these libraries available as imported targets for linking. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Find and check system libraries with PkgConfig Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/flutter/CMakeLists.txt This section uses PkgConfig to find and check for required system libraries like GTK, GLIB, and GIO. It ensures these dependencies are available before proceeding with the build. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Basic Dart Variable Declaration Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_result/README.md Declare a constant string variable in Dart. This is a fundamental example for setting up basic values. ```dart const like = 'sample'; ``` -------------------------------- ### Cross-Building Sysroot Configuration Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Sets up the sysroot and search paths for cross-compilation. This is used when building the application for a different target platform than the build machine. ```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() ``` -------------------------------- ### Configure Flutter Library and Headers Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_backend/example/windows/flutter/CMakeLists.txt Sets up the Flutter library and its associated header files. This includes defining the path to the Flutter DLL and ICU data file, and listing the necessary header files for the Flutter interface. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Add Dependencies and Include Directories Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/runner/CMakeLists.txt Specifies libraries to link against and directories to include for the application target. Application-specific dependencies should be added here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Get Groups Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves groups (typically for Board view) from a database view. Prints the name and row count for each group. Handles potential errors. ```dart Future getGroups(String viewId) async { final payload = DatabaseViewIdPB(value: viewId); final result = await DatabaseEventGetGroups(payload).send(); result.fold( (groups) { for (final group in groups.items) { print('Group: ${group.groupName}'); print(' Rows: ${group.rows.length}'); } }, (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Build AppFlowy Debian Package Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/scripts/linux_distribution/deb/README.md Execute this script to build the .deb package. Ensure you have the Linux production release and version information ready. The output deb file will be located in the specified release path. ```bash cd frontend/ sh scripts/linux_distribution/deb/build_deb.sh [LINUX_PRODUCTION_RELEASE_PATH] [VERSION] [PACKAGE_NAME] ``` ```bash # for example sh scripts/linux_distribution/deb/build_deb.sh appflowy_flutter/product/0.2.9/linux/Release 0.2.9 AppFlowy_0.2.9.deb ``` -------------------------------- ### Get Cell Data Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves the data and field type for a specific cell. Requires view ID, row ID, and field ID. Handles potential errors. ```dart Future getCell(String viewId, String rowId, String fieldId) async { final payload = CellIdPB() ..viewId = viewId ..rowId = rowId ..fieldId = fieldId; final result = await DatabaseEventGetCell(payload).send(); result.fold( (cell) { print('Cell data: ${cell.data}'); print('Field type: ${cell.fieldType}'); }, (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/runner/CMakeLists.txt Applies a predefined set of standard build settings to the target executable. This can be customized for applications requiring different build configurations. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Set Up Ephemeral Directory Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/windows/flutter/CMakeLists.txt Configures the ephemeral directory for generated files, typically used for Flutter integration. ```cmake cmake_minimum_required(VERSION 3.15) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Database Events Enum (Rust) Source: https://context7.com/appflowy-io/appflowy/llms.txt Defines database-related events for the Rust backend, including getting databases, creating fields/rows, and updating cells. Uses Protocol Buffers for input/output. ```rust // Database events defined in flowy-database2/src/event_map.rs #[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)] #[event_err = "FlowyError"] pub enum DatabaseEvent { #[event(input = "DatabaseViewIdPB", output = "DatabasePB")] GetDatabase = 0, #[event(input = "CreateFieldPayloadPB", output = "FieldPB")] CreateField = 24, #[event(input = "CreateRowPayloadPB", output = "RowMetaPB")] CreateRow = 50, #[event(input = "CellChangesetPB")] UpdateCell = 71, #[event(input = "DatabaseViewIdPB", output = "RepeatedGroupPB")] GetGroups = 100, #[event(input = "SummaryRowPB")] SummarizeRow = 174, } ``` -------------------------------- ### Find and Link GTK+ Dependency Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Finds the PkgConfig tool and checks for the gtk+-3.0 library, making it available for linking. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Folder Events Enum (Rust) Source: https://context7.com/appflowy-io/appflowy/llms.txt Defines folder and view management events for the Rust backend, including creating, getting, deleting, and moving views. Uses Protocol Buffers for input/output. ```rust // Folder events for view management #[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)] #[event_err = "FlowyError"] pub enum FolderEvent { #[event(output = "WorkspacePB")] ReadCurrentWorkspace = 2, #[event(input = "CreateViewPayloadPB", output = "ViewPB")] CreateView = 10, #[event(input = "ViewIdPB", output = "ViewPB")] GetView = 11, #[event(input = "RepeatedViewIdPB")] DeleteView = 13, #[event(input = "MoveNestedViewPayloadPB")] MoveNestedView = 32, #[event(input = "PublishViewParamsPB")] PublishView = 43, } ``` -------------------------------- ### Configure Build Types (Multi-Config Generators) Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_backend/example/windows/CMakeLists.txt Sets the available build configurations (Debug, Profile, Release) for multi-configuration build systems like Visual Studio. ```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() ``` -------------------------------- ### Get Appflowy Workspace Members Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves a list of members for a given workspace ID. It iterates through the members and prints their names, emails, and roles. Includes error handling for the retrieval process. ```dart // Get workspace members Future getWorkspaceMembers(String workspaceId) async { final data = QueryWorkspacePB()..workspaceId = workspaceId; final result = await UserEventGetWorkspaceMembers(data).send(); result.fold( (members) { for (final member in members.items) { print('Member: ${member.name} (${member.email})'); print(' Role: ${member.role}'); } }, (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Define Flutter Library and Related Files Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/flutter/CMakeLists.txt Specifies the path to the Flutter Windows DLL and ICU data file, and the Dart FFI DLL. These are published to the parent scope for use in the install step. ```cmake # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(DART_FFI_DLL "${CMAKE_CURRENT_SOURCE_DIR}/dart_ffi/dart_ffi.dll" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Basic Popover Usage Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/README.md Demonstrates the basic structure of a Popover component, including trigger actions, child widget, direction, and the popup builder. ```dart Popover( // Define how to trigger the popover triggerActions: PopoverTriggerActionFlags.click, child: TextButton(child: Text("Popover"), onPressed: () {}), // Define the direction of the popover direction: PopoverDirection.bottomWithLeftAligned, popupBuilder(BuildContext context) { return PopoverMenu(); }, ); ``` -------------------------------- ### Get a View by ID Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves a specific view using its unique ID. This function returns details such as the view's name, layout, parent ID, number of children, and favorite status. ```dart // Get a view by ID Future getView(String viewId) async { final payload = ViewIdPB.create()..value = viewId; final result = await FolderEventGetView(payload).send(); result.fold( (view) { print('View: ${view.name}'); print('Layout: ${view.layout}'); print('Parent: ${view.parentViewId}'); print('Children: ${view.childViews.length}'); print('Is favorite: ${view.isFavorite}'); }, (error) => print('View not found: ${error.msg}'), ); } ``` -------------------------------- ### Define C++ wrapper sources Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt Lists the C++ source files for the wrapper library, categorized by core, plugin, and application components. Paths are prepended with the wrapper root directory. ```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}/") ``` -------------------------------- ### Set Project and Binary Names Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Configures the minimum CMake version, project name, and the desired binary executable name. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "AppFlowy") set(APPLICATION_ID "io.appflowy.appflowy") ``` -------------------------------- ### Integrate ViewBloc with Flutter Widget Source: https://context7.com/appflowy-io/appflowy/llms.txt This example shows how to use BlocProvider and BlocBuilder to integrate the ViewBloc into a Flutter widget. It dispatches an initial event and builds a ListTile to display the view name and handle delete actions. ```dart // Usage in Flutter widget class ViewWidget extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => ViewBloc(view: myView)..add(const ViewEvent.initial()), child: BlocBuilder( builder: (context, state) { return ListTile( title: Text(state.view.name), onTap: () => context.read().add(const ViewEvent.setIsExpanded(true)), trailing: IconButton( icon: Icon(Icons.delete), onPressed: () => context.read().add(const ViewEvent.delete()), ), ); }, ), ); } } ``` -------------------------------- ### AppFlowy User Authentication Methods Source: https://context7.com/appflowy-io/appflowy/llms.txt Demonstrates how to sign in using email and password, send a magic link for passwordless authentication, retrieve the current user's profile, and sign out. ```dart import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'; // Sign in with email and password Future signInWithEmailPassword() async { final payload = SignInPayloadPB( email: 'user@example.com', password: 'securePassword123', ); final result = await UserEventSignInWithEmailPassword(payload).send(); result.fold( (tokenResponse) { print('Login successful: ${tokenResponse.accessToken}'); // Store tokens and initialize user session }, (error) { print('Login failed: ${error.msg}'); }, ); } // Sign in with magic link (passwordless) Future signInWithMagicLink() async { final payload = MagicLinkSignInPB( email: 'user@example.com', redirectTo: 'https://app.appflowy.com/callback', ); final result = await UserEventMagicLinkSignIn(payload).send(); result.fold( (userProfile) => print('Magic link sent to ${userProfile.email}'), (error) => print('Error: ${error.msg}'), ); } // Get current user profile Future getCurrentUser() async { final result = await UserEventGetUserProfile().send(); result.fold( (profile) { print('User: ${profile.name}'); print('Email: ${profile.email}'); print('User ID: ${profile.id}'); }, (error) => print('Not authenticated: ${error.msg}'), ); } // Sign out Future signOut() async { await UserEventSignOut().send(); print('User signed out successfully'); } ``` -------------------------------- ### Get Document Plain Text Content Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves the plain text content of a document. This is useful for indexing, searching, or displaying document content as simple text. It dispatches an event and prints the text or an error message. ```dart // Get document text content Future getDocumentText(String documentId) async { final payload = OpenDocumentPayloadPB()..documentId = documentId; final result = await DocumentEventGetDocumentText(payload).send(); result.fold( (textContent) => print('Document text: ${textContent.text}'), (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Create plugin wrapper library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt Builds a STATIC C++ library for the Flutter plugin wrapper. It includes core and plugin-specific sources, applies standard settings, and links against the 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) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_backend/example/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support in the project. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Get Document Data without Opening Source: https://context7.com/appflowy-io/appflowy/llms.txt Retrieves document data, including block count and types, without fully opening the document. Useful for quick checks or pre-rendering information. Handles success by iterating through blocks or failure with an error message. ```dart // Get document data without opening Future getDocumentData(String documentId) async { final payload = OpenDocumentPayloadPB()..documentId = documentId; final result = await DocumentEventGetDocumentData(payload).send(); result.fold( (data) { print('Document has ${data.blocks.length} blocks'); for (final entry in data.blocks.entries) { print('Block ${entry.key}: ${entry.value.ty}'); } }, (error) => print('Error: ${error.msg}'), ); } ``` -------------------------------- ### Set Project and Binary Name Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/CMakeLists.txt Initializes the CMake project and sets the name of the final executable. Requires CMake version 3.14 or higher. ```cmake cmake_minimum_required(VERSION 3.14) project(appflowy_flutter LANGUAGES CXX) set(BINARY_NAME "AppFlowy") ``` -------------------------------- ### Create application wrapper library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/windows/flutter/CMakeLists.txt Builds a STATIC C++ library for the Flutter application runner. It includes core and application-specific sources, and links against the 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) ``` -------------------------------- ### Project and Executable Configuration Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, and the executable's on-disk name. Also defines the unique GTK application identifier. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") ``` -------------------------------- ### Create Flutter Wrapper Plugin Library Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/windows/flutter/CMakeLists.txt Builds a static C++ library for Flutter plugins, linking against the Flutter library and setting visibility properties. ```cmake # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Include Generated Plugin Rules Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Includes CMake rules for building and registering generated plugins. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Application Executable Definition Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_popover/example/linux/CMakeLists.txt Defines the main application executable target. Source files, including generated plugin registration, are listed here. Changing BINARY_NAME above is recommended for renaming. ```cmake # Define the application target. To change its name, change BINARY_NAME above, # 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} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Define Flutter Library and Headers Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/windows/flutter/CMakeLists.txt Sets up variables for the Flutter library DLL and its associated header files, making them available to parent scopes. ```cmake # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Define and configure Flutter library headers Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/flutter/CMakeLists.txt Appends a list of Flutter library header files and then uses the custom `list_prepend` function to add a directory prefix. This prepares the headers for inclusion in the build. ```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/") ``` -------------------------------- ### Define C++ Wrapper Sources Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/flowy_infra_ui/example/windows/flutter/CMakeLists.txt Lists and transforms paths for C++ wrapper source files, categorizing them for core, plugin, and application targets. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Build AppFlowy Docker Image Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/scripts/docker-buildfiles/README.md Use this command to build the AppFlowy Docker image. It accepts build arguments for user (uid) and group (gid) to ensure correct file permissions within the container. ```bash docker-compose build --build-arg uid=$(id -u) --build-arg gid=$(id -g) ``` -------------------------------- ### Copy libc++_shared.so for armeabi-v7a Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/android/app/src/main/CMakeLists.txt Copies the libc++_shared.so library for the armeabi-v7a architecture from the Android NDK to the jniLibs directory. Ensure ANDROID_NDK is set. ```cmake file(COPY ${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/jniLibs/armeabi-v7a ) ``` -------------------------------- ### Configure Binary Name and RPATH Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/packages/appflowy_backend/example/windows/CMakeLists.txt Sets the name of the executable binary and configures the runtime search path for libraries. ```cmake set(BINARY_NAME "flowy_sdk_example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Set Wrapper Root and Fallback Platform Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/windows/flutter/CMakeLists.txt Defines the root directory for the C++ client wrapper and sets a fallback for FLUTTER_TARGET_PLATFORM if it's not already defined. This ensures a default platform is used when not explicitly specified. ```cmake # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Configure RPATH and Cross-Building Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/linux/CMakeLists.txt Sets the RPATH for libraries and configures sysroot for cross-compilation environments. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. 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() ``` -------------------------------- ### Cargo Configuration for Android Targets Source: https://github.com/appflowy-io/appflowy/blob/main/frontend/appflowy_flutter/android/README.md Configure your ~/.cargo/config file to specify the correct linker and archiver paths for different Android architectures. Ensure 'user' and NDK paths are updated to match your system. ```toml [target.aarch64-linux-android] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang" [target.armv7-linux-androideabi] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang" [target.i686-linux-android] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang" [target.x86_64-linux-android] ar = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" linker = "/home/user/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang" ```