### Installation: Bundle Directory Setup Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Configures the installation prefix to a build bundle directory and ensures this directory is cleaned before each installation. ```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 Configuration Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Configures installation paths and ensures the 'install' step is default for Visual Studio builds. Sets the installation prefix to be adjacent to the executable. ```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}") ``` -------------------------------- ### Basic Controller Setup Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Defines a controller with a base path and a GET endpoint. The value passed to `@Controller()` sets a route prefix for all methods within the class. ```APIDOC ## @Controller('/users') ### Description Defines a class that handles HTTP routes with a base path prefix. ### Example ```dart @Controller('/users') class UserController { @Get('/all') String getAll() => 'Listing all users'; } ``` This maps to the HTTP route `/users/all`. ``` -------------------------------- ### Install Application Executable Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the installation bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Start Local Development Server Source: https://github.com/flutterando/vaden/blob/main/doc/README.md Starts a local development server for live previewing changes. The server automatically reloads on file changes. ```bash $ yarn start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/flutterando/vaden/blob/main/doc/README.md Installs project dependencies using Yarn. This is the first step before running any other commands. ```bash $ yarn ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the library directory if they exist. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Define Installation Directories Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Sets variables for the installation directories within the bundle, such as 'data' and library locations. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Vaden Application Configuration Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/project_structure.md An example of an application.yaml file used to configure global settings for a Vaden application, including server details, database access, and OpenAPI metadata. ```yaml server: port: 8080 host: localhost database: provider: postgres postgres: host: localhost port: 5432 database: my_app username: user password: pass openapi: title: My API version: 1.0.0 description: Auto-generated by Vaden ``` -------------------------------- ### Plugin Build Rules and Installation Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/linux/CMakeLists.txt Includes generated plugin build rules and defines installation targets for the application bundle, including executable, data, libraries, and assets. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.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") 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) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # 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. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Application Executable and Data Files Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Installs the main application executable, ICU data file, Flutter library, and bundled plugin libraries to the specified runtime destinations. ```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() ``` -------------------------------- ### Project Setup and Versioning Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Sets the minimum CMake version and project name. It's essential for initializing the build environment. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### ProductApi Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/flutter-vaden.mdx Example of an API client interface using @ApiClient annotation for defining RESTful API endpoints. ```APIDOC ## @ApiClient ProductApi ### Description Defines a RESTful API client for product-related operations. ### Method - GET - POST - PUT - DELETE ### Endpoint - `/product/` - `/product` - `/products` ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the product. #### Request Body - **product** (ProductDTO) - Required - The product data for create/update operations. ### Request Example ```json { "example": "{\"id\": 1, \"name\": \"Example Product\", \"price\": 100.0}" } ``` ### Response #### Success Response (200) - **ProductDTO** - The product data. - **List** - A list of product data. - **void** - Indicates successful deletion. #### Response Example ```json { "example": "{\"id\": 1, \"name\": \"Example Product\", \"price\": 100.0}" } ``` ``` -------------------------------- ### HttpSecurity Example with Rules Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/vaden-security.mdx An example demonstrating HttpSecurity configuration with various request matchers for public access, specific method restrictions, and general authentication requirements. ```dart @Bean() HttpSecurity httpSecurity() { return HttpSecurity([ // Public access to auth and docs RequestMatcher('/auth/**').permitAll(), RequestMatcher('/docs/**').permitAll(), // Allow only GET to "/public" RequestMatcher('/public', HttpMethod.get).permitAll(), // Restrict DELETE on /admin/** to "admin" role RequestMatcher('/admin/**', HttpMethod.delete).hasRole('admin'), // Secure everything else AnyRequest().authenticated(), ]); } ``` -------------------------------- ### Install Dependencies Source: https://github.com/flutterando/vaden/blob/main/doc/docs/Introduction/getting-started.md Installs the necessary Dart project dependencies. Run this command in your project's root directory. ```sh dart pub get ``` -------------------------------- ### Install Native Assets Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Installs native assets provided by packages into the bundle's lib directory. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Basic Controller with Route Prefix Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Define a controller with a base path for all its routes. This example maps to '/users/all'. ```dart @Controller('/users') class UserController { @Get('/all') String getAll() => 'Listing all users'; } ``` -------------------------------- ### Install Bundled Libraries Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Installs the main Flutter library and any bundled plugin libraries into the bundle's lib directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install AOT Library Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compilation library, but only for Profile and Release build configurations. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Application Executable and Data Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Installs the main application executable to the bundle's root and Flutter's ICU data file to the data directory. ```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) ``` -------------------------------- ### Vaden Application Entry Point Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/project_structure.md The main Dart file for your Vaden application. It initializes the Vaden application, sets up configurations, and starts the HTTP server. ```dart import 'package:example/vaden_application.dart'; Future main(List args) async { final vaden = VadenApplicationImpl(); await vaden.setup(); final server = await vaden.run(args); print('Server listening on port ${server.port}'); } ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring it's fully re-copied on each build to avoid stale files. ```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 Native Assets Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Installs native assets provided by the build.dart script into the application's runtime directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Set Installation Prefix for Bundled App Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable for in-place running, especially for Visual Studio integration. ```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() ``` -------------------------------- ### ApplicationRunner Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/warm_up.md Use `ApplicationRunner` for tasks that must run at application startup, such as database preparation or logger initialization. ```dart @Component() class AppWarmup implements ApplicationRunner { @override Future run(VadenApplication app) async { await prepareDatabase(); initializeLogger(); } } ``` -------------------------------- ### Project and CMake Version Setup Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Sets the minimum required CMake version and the project name. It also explicitly opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.14) project(app LANGUAGES CXX) set(BINARY_NAME "app") cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Run Vaden Server with Docker Source: https://github.com/flutterando/vaden/blob/main/vaden_generator/backend/README.md Start the Vaden server from its Docker image. This command maps port 8080 from the host to the container and runs the server. ```bash $ docker run -it -p 8080:8080 myserver Server listening on port 8080 ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Installs the Flutter assets directory into the bundle's data directory, ensuring it's cleared and re-copied on each build. ```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 ICU Data File Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/CMakeLists.txt Installs the ICU data file, which is required for internationalization, to the data directory. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Run Server with Dart SDK Source: https://github.com/flutterando/vaden/blob/main/vaden/example/README.md Execute the Shelf server application directly using the Dart SDK. Ensure the Dart SDK is installed and configured. ```bash $ dart run bin/server.dart Server listening on port 8080 ``` -------------------------------- ### Run Flutter Pub Get Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/flutter-vaden.mdx Execute this command after updating your pubspec.yaml to fetch the newly added dependencies. ```bash flutter pub get ``` -------------------------------- ### Test Server Endpoints with Curl Source: https://github.com/flutterando/vaden/blob/main/vaden/example/README.md Use curl to send GET requests to the root and echo endpoints of the running Shelf server. Verify the responses. ```bash $ curl http://0.0.0.0:8080 Hello, World! ``` ```bash $ curl http://0.0.0.0:8080/echo/I_love_Dart I_love_Dart ``` -------------------------------- ### Simple Root Module Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/vaden_module.md Define a root application module that imports other modules like DomainModule and VadenSecurity. Vaden's DI system makes components from imported modules available application-wide. ```dart @VadenModule([ DomainModule, VadenSecurity, // Imports all providers and configurations from VadenSecurity ]) class AppModule {} ``` -------------------------------- ### Install Vaden MCP Globally Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/vaden-mcp.mdx Install Vaden MCP globally using Dart's package manager. Ensure you have Dart SDK 3.10.0 or higher. ```bash dart pub global activate vaden_mcp ``` -------------------------------- ### Run Class Scanner with build_runner Source: https://github.com/flutterando/vaden/blob/main/doc/docs/Introduction/getting-started.md Starts the build runner in watch mode to enable the Class Scanner for metaprogramming. This is essential for development. ```sh dart run build_runner watch ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library into the bundle's lib directory, but only for non-Debug build configurations. ```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() ``` -------------------------------- ### CommandLineRunner Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/warm_up.md Implement `CommandLineRunner` to conditionally execute tasks based on command-line arguments like 'migrate' or 'seed'. ```dart @Component() class AppRunner implements CommandLineRunner { @override Future run(List args) async { if (args.contains('migrate')) { await runMigrations(); } else if (args.contains('seed')) { await seedDatabase(); } } } ``` -------------------------------- ### Project and Build Configuration Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, executable name, and application ID. It also includes modern CMake policy settings and defines the installation path for bundled libraries. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Manual Bean Registration with Configuration Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/component.md Use @Configuration() and @Bean() to manually register instances, especially when initialization requires parameters or asynchronous setup. The DI container resolves method parameters automatically. ```dart import 'package:vaden/vaden.dart'; @Configuration() class AppConfiguration { @Bean() Logger logger() => Logger(); @Bean() Future api(ApplicationSettings settings) async { return ApiClient(baseUrl: settings['api']['url']); } } ``` -------------------------------- ### Constructor Injection Example Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/component.md Inject dependencies into a component's constructor. The DI container automatically resolves and provides instances of required types. ```dart import 'package:vaden/vaden.dart'; @Service() class UserService { final Logger logger; UserService(this.logger); void createUser() => logger.log('User created'); } ``` -------------------------------- ### Initialize Flutter App with VadenApp Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/flutter-vaden.mdx Use the generated VadenApp class in your main function's runApp method to start your Flutter application with Vaden's capabilities. ```dart void main() { runApp(VadenApp()); } ``` -------------------------------- ### Project-level CMake Configuration Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/linux/CMakeLists.txt Sets the minimum CMake version, project name, and executable name. It also defines the application ID and configures installation paths for libraries. ```cmake cmake_minimum_required(VERSION 3.13) 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 "app") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.app") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # 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() # Define build configuration options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Build and Run Server with Docker Source: https://github.com/flutterando/vaden/blob/main/vaden/example/README.md Build a Docker image for the Shelf server and run it as a container. Map the host port 8080 to the container's port 8080. ```bash $ docker build . -t myserver $ docker run -it -p 8080:8080 myserver Server listening on port 8080 ``` -------------------------------- ### Build Vaden Server Docker Image Source: https://github.com/flutterando/vaden/blob/main/vaden_generator/backend/README.md Create a Docker image for the Vaden server application. This command tags the image as 'myserver' for subsequent use. ```bash $ docker build . -t myserver ``` -------------------------------- ### Initialize VadenApp in main Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/README.md Use the generated VadenApp class in your runApp method to bootstrap the application with Vaden's services. ```dart void main() { runApp(VadenApp( child: MyApp(), )); } ``` -------------------------------- ### Extracting Route Parameters Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Use the @Param decorator to extract values from the URL path. The example maps to '/user/2'. ```dart @Get('/user/') String getUser(@Param('id') int id) => 'User $id'; ``` -------------------------------- ### Define Application and Command Line Runners Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/warm_up.md Create classes implementing `ApplicationRunner` for general startup tasks and `CommandLineRunner` for argument-specific tasks. Both should be annotated with `@Component()`. ```dart import 'package:vaden/vaden.dart'; @Component() class AppWarmup implements ApplicationRunner { @override Future run(VadenApplication app) async { print('ApplicationRunner'); } } @Component() class AppRunner implements CommandLineRunner { @override Future run(List args) async { print('My args: $args'); } } ``` -------------------------------- ### Run the Vaden Project Source: https://github.com/flutterando/vaden/blob/main/doc/docs/Introduction/getting-started.md Executes the main server file of your Vaden project. This command can be run directly or via IDE shortcuts. ```sh dart run bin/server.dart ``` -------------------------------- ### Find System Libraries Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries like GTK, GLIB, and GIO, making their imported targets available. ```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) ``` -------------------------------- ### Extracting Route Parameters by Variable Name Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md When the parameter name is omitted in @Param, it defaults to the variable name. Example maps to '/product/123'. ```dart @Get('/product/') String getProduct(@Param() String id) => 'Product $id'; ``` -------------------------------- ### Deploy Website Using SSH Source: https://github.com/flutterando/vaden/blob/main/doc/README.md Deploys the website using SSH. This command is useful for automated deployment pipelines. ```bash $ USE_SSH=true yarn deploy ``` -------------------------------- ### Extracting Query Parameters Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Use the @Query decorator to extract values from the URL query string. The example maps to '/search?term=Text'. ```dart @Get('/search') String search(@Query('term') String term) => 'Searching $term'; ``` -------------------------------- ### Build Static Website Content Source: https://github.com/flutterando/vaden/blob/main/doc/README.md Generates the static website files into the 'build' directory. These files can be hosted on any static hosting service. ```bash $ yarn build ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Sets the minimum CMake version and defines the ephemeral directory for generated files. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Export Flutter Library and ICU Data Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Publishes the Flutter library path and ICU data file to the parent scope for use in the install step. ```cmake # 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) ``` -------------------------------- ### Controller with Dependency Injection Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Demonstrates a controller that utilizes constructor injection to obtain a service dependency. The service is automatically injected if registered. ```APIDOC ## @Controller('/hello') ### Description Groups routes under `/hello` and injects `HelloService` via the constructor. ### Example ```dart @Controller('/hello') class HelloController { final HelloService helloService; helloController(this.helloService); @Get('/ping') Response ping() => Response.ok(helloService.ping()); } ``` ``` -------------------------------- ### Define a Basic DTO Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/dto.mdx Annotate a class with @DTO() to enable automatic JSON conversion, validation, and schema generation. This example defines a simple DTO for credentials. ```dart @DTO() class Credentials with Validator { final String username; final String password; const Credentials(this.username, this.password); } ``` -------------------------------- ### Prepending Wrapper Root to App Sources Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Prepends the wrapper root directory path to each source file in the CPP_WRAPPER_SOURCES_APP list. ```cmake list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Global Exception Handler with @ControllerAdvice Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/exception-handling.md Define a global exception handler using @ControllerAdvice to intercept and manage specific exceptions. This example shows handling ResponseException and a generic Exception. ```dart @ControllerAdvice() class AppControllerAdvice { final DSON _dson; AppControllerAdvice(this._dson); @ExceptionHandler(ResponseException) Future handleResponseException(ResponseException e) async { return e.generateResponse(_dson); } @ExceptionHandler(Exception) Response handleGeneric(Exception e) { return Response.internalServerError( body: jsonEncode({'message': 'Internal server error'}) ); } } ``` -------------------------------- ### Customize JSON Key with @JsonKey() Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/dto.mdx Use the @JsonKey() annotation to specify a different key name in the JSON payload than the Dart field name. This example maps 'user_name' in JSON to the 'username' field. ```dart @DTO() class Credentials with Validator { @JsonKey('user_name') String username; String password; Credentials(this.username, this.password); } ``` -------------------------------- ### Documenting a Controller Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/openapi.mdx Annotate your controller with `@Api()` to include it in the OpenAPI documentation. You can also provide a tag and description for the controller. ```APIDOC ## @Api() Controller ### Description Annotates a controller to include it in the OpenAPI documentation. ### Usage ```dart @Api(tag: 'auth', description: 'Authentication endpoints') @Controller('/auth') class AuthController { // ... controller methods } ``` ### Parameters - **tag** (string, optional) - A tag to group endpoints. - **description** (string, optional) - A description for the controller. ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/linux/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be removed if the application requires custom build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/runner/CMakeLists.txt Adds necessary dependency libraries and include directories for the application. Custom 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_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Define an HTTP Controller Source: https://github.com/flutterando/vaden/blob/main/doc/docs/Introduction/core-concepts.mdx Use the @Controller() annotation to define the base route for an HTTP controller. Methods within the controller can be annotated with HTTP verbs like @Get(). Controllers support constructor injection for dependencies. ```dart @Controller('/auth') class AuthController { final AuthService authService; AuthController(this.authService); @Get('/ping') Response ping() => Response.ok(authService.ping()); } ``` -------------------------------- ### C++ Wrapper Application Sources Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Lists C++ wrapper source files for the application runner and prepends the wrapper root directory. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### DTO with Nested Objects and Custom Parsing Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/dto.mdx DTOs can contain other DTOs. Use @UseParse() to specify a custom parser for fields, such as handling complex types like files. This example uses FileParse for base64 encoding/decoding files. ```dart @DTO() class UserDocument { final String title; final String description; // Custom parser for File - converts to base64 string @UseParse(FileParse) final File? attachment; const UserDocument(this.title, this.description, this.attachment); } // Custom parser for File type class FileParse extends ParamParse { const FileParse(); @override String? toJson(File? param) { if (param == null) return null; // Convert file to base64 string for JSON transport final bytes = param.readAsBytesSync(); return base64Encode(bytes); } @override File? fromJson(String? json) { if (json == null) return null; // Create temporary file from base64 string final bytes = base64Decode(json); final tempFile = File('temp_${DateTime.now().millisecondsSinceEpoch}'); tempFile.writeAsBytesSync(bytes); return tempFile; } } ``` -------------------------------- ### Listing Plugin Wrapper Sources Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Appends C++ source files for plugin registration to the CPP_WRAPPER_SOURCES_PLUGIN variable. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) ``` -------------------------------- ### Define Flutter Library and Headers Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/flutter/CMakeLists.txt This section defines the path to the Flutter Linux GTK shared library and its associated header files. It also sets up variables for the ICU data file and project build directory, publishing them to the parent scope for use in 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) ``` ```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/") ``` -------------------------------- ### Implement UserDetailsService Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/vaden-security.mdx Implement the UserDetailsService interface to provide user details by username. This service is crucial for the authentication process. ```dart import 'package:vaden/vaden.dart'; import 'package:vaden_security/vaden_security.dart'; @Service() class UserDetailsServiceImpl implements UserDetailsService { @override Future loadUserByUsername(String username) async { ... } } ``` -------------------------------- ### Defining the Application Module Source: https://github.com/flutterando/vaden/blob/main/doc/docs/full_stack_migration/frontend_application.md Create an AppModule annotated with @VadenModule to list all other modules your application depends on, such as DomainModule and AppConfig. ```dart @VadenModule([DomainModule, AppConfig]) class AppModule {} ``` -------------------------------- ### Build Configuration Handling Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Configures the build types (Debug, Profile, Release) based on whether the generator is multi-config or single-config. ```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() ``` -------------------------------- ### Wildcard Routing with @Mount Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Explains how to use the `@Mount()` decorator for wildcard routing, suitable for advanced use cases such as handling WebSockets or acting as proxy handlers. ```APIDOC ## Wildcard Routing (`@Mount`) ### Description Handles wildcard endpoints, useful for advanced scenarios like WebSockets or proxying requests. ### Example: ```dart @Controller('/socket') class SocketController { @Mount('/chat') Response handle(Request request) { return websocketHandler(request); } } ``` ``` -------------------------------- ### Defining Global Middleware with Pipeline Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/middleware.md Use the Pipeline within your @Configuration class to add middlewares that apply to all incoming requests. You can add any Shelf middleware using addMiddleware or Vaden-specific middleware using addVadenMiddleware. ```dart @Configuration() class AppConfiguration { @Bean() ApplicationSettings settings() { return ApplicationSettings.load('application.yaml'); } @Bean() Pipeline globalMiddleware(ApplicationSettings settings) { return Pipeline() .addMiddleware(cors(allowedOrigins: ['*'])) .addVadenMiddleware(EnforceJsonContentType()) .addMiddleware(logRequests()); } } ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Loads Flutter's build rules from a subdirectory and checks for GTK+ 3.0 system dependencies using PkgConfig. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### C++ Wrapper Plugin Sources Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Lists C++ wrapper source files for plugins and prepends the wrapper root directory. ```cmake list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Listing App Wrapper Sources Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Appends C++ source files for the Flutter engine and view controller to the CPP_WRAPPER_SOURCES_APP variable. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) ``` -------------------------------- ### Cross-Building System Root Configuration Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Configures the CMake toolchain for cross-building by setting the system root and adjusting find root path modes. ```cmake # 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() ``` -------------------------------- ### VadenApp Widget Entry Point Source: https://github.com/flutterando/vaden/blob/main/doc/docs/full_stack_migration/frontend_application.md Use the generated VadenApp widget as the root of your Flutter application. It extends FlutterVadenApplication and integrates Vaden's services. ```dart void main() { runApp(VadenApp(child: const MyApp())); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Includes the CMake file that manages the building and integration of generated plugins. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Implementing a Custom Vaden Middleware Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/middleware.md Create a custom middleware by implementing the VadenMiddleware interface. The handle method receives the request and a next handler, allowing you to process the request before passing it to the next middleware or controller. ```dart class MyMiddleware implements VadenMiddleware { FutureOr handle(Request request, Handler next) async { return next(request); } } ``` -------------------------------- ### Documenting an Endpoint Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/openapi.mdx Use `@ApiOperation()` and `@ApiResponse()` to describe individual endpoints. You can specify a summary, description, and response details, including content schema. ```APIDOC ## @ApiOperation() and @ApiResponse() ### Description Provides detailed documentation for an API endpoint, including its purpose, expected responses, and content schema. ### Usage ```dart @ApiOperation(summary: 'Ping the server', description: 'Simple health check') @ApiResponse(200, description: 'Success') @Get('/ping') String ping() => 'pong'; @ApiResponse( 200, description: 'Successful login', content: ApiContent(type: 'application/json', schema: TokenResponse), ) @Post('/login') Future login(@Body() LoginRequest request) async { // Your login logic here } ``` ### Parameters for @ApiOperation - **summary** (string, required) - A short summary of the endpoint. - **description** (string, optional) - A detailed description of the endpoint. ### Parameters for @ApiResponse - **statusCode** (int, required) - The HTTP status code of the response. - **description** (string, optional) - A description of the response. - **content** (ApiContent, optional) - Specifies the content type and schema of the response. - **type** (string, required) - The content type (e.g., 'application/json'). - **schema** (Type, required) - The DTO class representing the response schema. ``` -------------------------------- ### Prepending Wrapper Root to Core Sources Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Prepends the wrapper root directory path to each source file in the CPP_WRAPPER_SOURCES_CORE list. ```cmake list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Define Application Configuration with Beans Source: https://github.com/flutterando/vaden/blob/main/doc/docs/Introduction/core-concepts.mdx Use @Configuration() and @Bean() to define application configuration and manage dependencies like services or middleware. Beans can be synchronous or asynchronous. ```dart @Configuration() class AppConfiguration { @Bean() Future storage(ApplicationSettings settings) { return Storage.createStorageService(settings); } @Bean() Pipeline globalMiddleware() { return Pipeline()..addMiddleware(logRequests()); } } ``` -------------------------------- ### Wrapper Root Directory Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Defines the root directory for the C++ client wrapper sources. ```cmake set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") ``` -------------------------------- ### Set Include Directories Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/linux/runner/CMakeLists.txt Configures the include directories for the target, allowing the compiler to find header files. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### View Server Logs Source: https://github.com/flutterando/vaden/blob/main/vaden/example/README.md Observe the server logs to see details of incoming HTTP requests, including method, status code, and path. This is useful for debugging. ```text 2021-05-06T15:47:04.620417 0:00:00.000158 GET [200] / 2021-05-06T15:47:08.392928 0:00:00.001216 GET [200] /echo/I_love_Dart ``` -------------------------------- ### C++ Wrapper Core Sources Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Lists core C++ wrapper source files and prepends 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}/") ``` -------------------------------- ### Listing Core Wrapper Sources Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Appends core C++ source files for the client wrapper to the CPP_WRAPPER_SOURCES_CORE variable. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) ``` -------------------------------- ### Registering a Basic Component Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/component.md Use the @Component() annotation to mark a class for automatic discovery and registration in the DI container. This is the foundation for all injectable classes. ```dart import 'package:vaden/vaden.dart'; @Component() class Logger { void log(String message) => print('[LOG] $message'); } ``` -------------------------------- ### Configure Claude Desktop for Vaden MCP Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/vaden-mcp.mdx Add this JSON configuration to your Claude Desktop config file to enable Vaden MCP integration. After adding, restart Claude Desktop. ```json { "mcpServers": { "vaden": { "command": "vaden_mcp", "args": [] } } } ``` -------------------------------- ### Executable Output Directory Configuration Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/linux/CMakeLists.txt Configures the runtime output directory for the main executable to a subdirectory, preventing direct execution of unbundled copies. ```cmake # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Configure Vaden Class Scanner Builder Source: https://github.com/flutterando/vaden/blob/main/doc/docs/addons/flutter-vaden.mdx Create a build.yaml file to enable the Vaden class scanner builder for Flutter projects. This configuration is necessary before running the build_runner command. ```yaml targets: $default: builders: vaden_class_scanner|aggregating_vaden_builder: enabled: true options: target: flutter ``` -------------------------------- ### Project Build Directory and AOT Library Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Sets the project build directory and the path to the Ahead-Of-Time (AOT) compiled library. ```cmake set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Parameter Extraction with @Param and @Query Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/controller.md Shows how to extract parameters from URL path segments and query strings using the `@Param` and `@Query` decorators. Supports basic types and nullable parameters. ```APIDOC ## Parameter Extraction ### Description Extracts data from URL path parameters and query strings using `@Param` and `@Query` decorators. ### Path Parameters (`@Param`): - **Usage**: Extracts values from the URL path. - **Example**: `@Get('/user/') String getUser(@Param('id') int id) => 'User $id';` ### Query Parameters (`@Query`): - **Usage**: Extracts values from the query string. - **Example**: `@Get('/search') String search(@Query('term') String term) => 'Searching $term';` ### Optional Parameters: - **Usage**: Declare parameters as nullable types to make them optional. - **Example**: `@Get('/search') Response search(@Query('term') String? term) => ...;` ### Supported Types: `String`, `int`, `double`, `bool`. ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Includes the configuration file generated by the Flutter tool. ```cmake # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Creating Flutter Wrapper App Library Source: https://github.com/flutterando/vaden/blob/main/flutter_vaden/example/windows/flutter/CMakeLists.txt Defines a STATIC library target 'flutter_wrapper_app' using core and application-specific wrapper sources. It 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) ``` -------------------------------- ### Unicode Support Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/CMakeLists.txt Enables Unicode support by defining preprocessor macros. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Module with Custom Configuration using CommonModule Source: https://github.com/flutterando/vaden/blob/main/doc/docs/basic-usage/vaden_module.md Configure a module by extending CommonModule and overriding the register method. This allows custom logic during app startup, such as adding middleware via the application's injector. ```dart @VadenModule([ UserDetails, Tokenization, VadenSecurityError, AuthController, ]) class VadenSecurity extends CommonModule { // The register method is called by Vaden during app startup. @override FutureOr register(DartVadenApplication app) { final injector = app.injector; // Get existing services from the injector var pipeline = injector.get(); // Add custom middleware pipeline = pipeline.addVadenMiddleware(GlobalSecurityMiddleware(...)); // Replace the old instance with the new one injector.replaceInstance(pipeline); // ... other configuration logic } } ``` -------------------------------- ### Flutter Library Headers Source: https://github.com/flutterando/vaden/blob/main/examples/todo/app/windows/flutter/CMakeLists.txt Lists and prepends the ephemeral directory to Flutter library header files. ```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}/") ```