### Run Minimal and Gallery Examples Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/README.md Commands to navigate to the example directory, fetch dependencies, and run either the minimal or the full gallery example. ```bash cd example flutter pub get flutter run # minimal example (lib/main.dart) flutter run -t lib/gallery.dart # full demo gallery ``` -------------------------------- ### Install liquid_glass_easy Package Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Add the liquid_glass_easy dependency to your pubspec.yaml file and run flutter pub get. ```yaml dependencies: liquid_glass_easy: ^3.0.0 ``` -------------------------------- ### Install Application Target Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/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) ``` -------------------------------- ### Installation Directories Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Defines the destination directories for data and libraries within the installation bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Flutter Library Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Installs the main Flutter library file to the application bundle's root directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Installs any bundled libraries from plugins to the application bundle's root directory. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installation Prefix Configuration Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Configures the installation prefix to be the build bundle directory by default, unless explicitly set otherwise. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Run Flutter Pub Get Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Execute this command in your terminal to fetch the added dependency. ```bash flutter pub get ``` -------------------------------- ### Install AOT Library Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-Debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set Installation Prefix for Bundle Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable for in-place running, especially for Visual Studio. ```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 AOT Library Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/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 Native Assets Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Installs native assets provided by the build.dart script from all packages into the application bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Minimal Liquid Glass Example Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/README.md A self-contained Flutter application demonstrating a single LiquidGlassLens over a background image. This example can be copied directly into a new Flutter project. ```dart import 'package:flutter/material.dart'; import 'package:liquid_glass_easy/liquid_glass_easy.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: Stack( fit: StackFit.expand, children: [ // Anything you want refracted behind the glass. Image.network('https://picsum.photos/800/1600', fit: BoxFit.cover), Center( child: SizedBox( width: 260, height: 150, child: LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.squircle(cornerRadius: 44), refraction: LiquidGlassRefraction( distortion: 0.13, distortionWidth: 34, ), ), child: const Center( child: Text( 'Liquid Glass', style: TextStyle(color: Colors.white, fontSize: 20), ), ), ), ), ), ], ), ), ); } } ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Installs bundled libraries provided by plugins to the lib directory within the bundle. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install RPATH Configuration Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Sets the RPATH to load bundled libraries from the lib/ directory relative to the binary. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Removes existing assets and then copies the Flutter assets directory to the application's data directory. This ensures assets are up-to-date. ```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 ICU Data File Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Installs the ICU data file to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Copies native assets provided by build.dart from all packages to the lib directory within the bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Clean Build Bundle Directory Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Installs a code that removes the build bundle directory before installation to ensure a clean state. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Set Flutter Library Path Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Sets the path to the Flutter library 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) ``` -------------------------------- ### System Dependencies Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Finds and checks for the GTK+ 3.0 PkgConfig modules. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Using LiquidGlassLens in a Widget Tree Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Demonstrates how to place a LiquidGlassLens anywhere in your widget tree. It adapts to layout constraints and its child's size. ```dart SizedBox( width: 220, height: 120, child: LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.squircle(cornerRadius: 36), ), child: const Center(child: Text('glass')), ), ) ``` -------------------------------- ### LiquidGlassView Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Initializes a LiquidGlassView, which acts as a background provider for Skia rendering. It takes a background widget and optionally a child UI containing LiquidGlassLens widgets. ```APIDOC ## `LiquidGlassView` Constructor ### Description Initializes a `LiquidGlassView`, serving as a background provider for Skia rendering. It requires a `backgroundWidget` that will be refracted by lenses and can optionally take a `child` widget tree containing `LiquidGlassLens` widgets. ### Parameters #### Named Parameters - **backgroundWidget** (`Widget`) - Required - The widget to be rendered as the background and refracted by the lenses. - **child** (`Widget?`) - Optional - Your UI, which should contain `LiquidGlassLens` widgets. - **pixelRatio** (`double`) - Optional - The pixel ratio for rendering. Defaults to `1.0`. - **realTimeCapture** (`bool`) - Optional - Whether to capture the background in real-time. Defaults to `true`. - **useSync** (`bool`) - Optional - Whether to use synchronous rendering. Defaults to `true`. - **useImpellerBackdrop** (`bool?`) - Optional - Overrides the engine's automatic detection for Impeller backdrop usage. - **refreshRate** (`LiquidGlassRefreshRate`) - Optional - Specifies the refresh rate for the background capture. Defaults to `LiquidGlassRefreshRate.deviceRefreshRate`. ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/runner/CMakeLists.txt Applies a predefined set of build settings to the specified target. This can be customized or removed if the application requires different build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Find and check GTK, GLIB, and GIO modules Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for the required GTK, GLIB, and GIO system libraries. These are essential for the Flutter GTK backend. ```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) ``` -------------------------------- ### Configure LiquidGlassView for Snapshot Capture (Skia) Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Use this configuration for static backgrounds. Manually refresh the capture after background changes using `captureOnce()`. ```dart final viewController = LiquidGlassViewController(); LiquidGlassView( controller: viewController, backgroundWidget: const MyBackground(), realTimeCapture: false, child: const MyGlassUI(), ); // Refresh manually after the background changes: await viewController.captureOnce(); ``` -------------------------------- ### Cross-building Sysroot Configuration Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Configures sysroot and find root path settings for cross-compilation environments. ```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() ``` -------------------------------- ### LiquidGlassLens Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Initializes a LiquidGlassLens widget. This widget is responsible for applying the liquid glass effect to its child. It allows customization of style, visibility, and backdrop usage. ```APIDOC ## `LiquidGlassLens` Constructor ### Description Initializes a LiquidGlassLens widget, which applies the liquid glass effect. The size is determined by layout constraints. The child is clipped to the lens shape, and padding can be added via a `Padding` widget. ### Parameters #### Named Parameters - **style** (`LiquidGlassStyle`) - Optional - The style to apply to the lens. Defaults to `LiquidGlassStyle()`. - **visibility** (`bool`) - Optional - Controls the instant show/hide of the lens. If false, the lens has no backdrop cost. Defaults to `true`. - **useImpellerBackdrop** (`bool?`) - Optional - Overrides the engine's automatic detection for Impeller backdrop usage. - **child** (`Widget?`) - Optional - The widget to be displayed within the lens, clipped to the lens shape. ``` -------------------------------- ### LiquidGlassView Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Defines the constructor for LiquidGlassView, which acts as a Skia background provider. It requires a background widget and allows configuration of pixel ratio and capture settings. ```dart LiquidGlassView({ required Widget backgroundWidget, // refracted by lenses on Skia Widget? child, // your UI, containing LiquidGlassLens widgets double pixelRatio = 1.0, bool realTimeCapture = true, bool useSync = true, bool? useImpellerBackdrop, LiquidGlassRefreshRate refreshRate = LiquidGlassRefreshRate.deviceRefreshRate, }) ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Includes CMake scripts to manage building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Configure Flutter Tool Backend Command Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend script. This command generates necessary output files like the Flutter library and headers. A phony output file is used to ensure the command runs on every build. ```cmake # _phony_ is a non-existent file to force this command to run every time, since currently there's no way to get a full input/output list from the flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) ``` -------------------------------- ### Configure Optical Border Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Use OpticalBorder for a default Apple-style rim light. Adjust border saturation, ambient intensity, and solidity for desired effects. ```dart LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.squircle( cornerRadius: 36, borderType: OpticalBorder( borderSaturation: 1.5, ambientIntensity: 1.0, borderSolidity: 0.0, ), ), ), ) ``` -------------------------------- ### LiquidGlassShape Constructors Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Illustrates the different constructors for LiquidGlassShape, enabling selection of corner styles like rounded rectangle, squircle, and continuous rounded rectangle. ```dart LiquidGlassShape.roundedRectangle(cornerRadius: ...) LiquidGlassShape.squircle(cornerRadius: ...) LiquidGlassShape.continuousRoundedRectangle(cornerRadius: ...) ``` -------------------------------- ### Project and Minimum CMake Version Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Sets the minimum required CMake version and the project name. ```cmake cmake_minimum_required(VERSION 3.14) project(liquid_glass_easy_example LANGUAGES CXX) ``` -------------------------------- ### Basic Liquid Glass Lens on Impeller Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Demonstrates the simplest case of using LiquidGlassLens for true liquid glass visuals on Impeller. No background widget is required. ```dart import 'package:flutter/material.dart'; import 'package:liquid_glass_easy/liquid_glass_easy.dart'; class DemoGlass extends StatelessWidget { const DemoGlass({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Stack( fit: StackFit.expand, children: [ Image.asset('assets/bg.jpg', fit: BoxFit.cover), Center( child: SizedBox( width: 260, height: 150, child: LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.squircle(cornerRadius: 44), refraction: LiquidGlassRefraction( distortion: 0.13, distortionWidth: 34, ), ), child: const Center(child: Text('Liquid Glass')), ), ), ), ], ), ); } } ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt A function to apply standard compilation features, options, and definitions to a target. Use with caution for plugins. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Project and Minimum CMake Version Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Sets the minimum required CMake version and defines the project name and languages. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) ``` -------------------------------- ### Set Binary Name Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Defines the name of the executable file for the application. ```cmake set(BINARY_NAME "liquid_glass_easy_example") ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Defines linker and compiler flags for the Profile build mode, often inheriting from Release settings. ```cmake set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Liquid Glass Lens with Background on Skia Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Shows how to configure LiquidGlassLens to refract a captured background on Skia by wrapping it in LiquidGlassView. The backgroundWidget is required for Skia. ```dart LiquidGlassView( backgroundWidget: const MyBackground(), // required on Skia child: Center( child: SizedBox( width: 300, height: 160, child: LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.squircle(cornerRadius: 40), refraction: LiquidGlassRefraction(distortion: 0.12, distortionWidth: 30), ), child: const Center(child: Text('refracts the captured background')), ), ), ), ) ``` -------------------------------- ### Unicode Support Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Adds definitions to enable Unicode support for all projects. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Define Static Library for Plugin Wrapper Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Creates a static library for the C++ wrapper used by Flutter plugins. It includes core and plugin-specific source files and links against the Flutter library. ```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}/") # 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) ``` -------------------------------- ### Add Include Directories Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/runner/CMakeLists.txt Specifies the include directories for the application target. The source directory is added as a private include directory. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Define custom command for Flutter tool backend Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/flutter/CMakeLists.txt A custom command to execute the Flutter tool backend script. It's set up to run every time by using a dummy output file '_phony_' to ensure the build artifacts are generated. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Applies standard compilation features, options, and definitions to a target. Be cautious adding new options here as plugins use this by default. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### LiquidGlassLens Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Defines the constructor for the LiquidGlassLens widget. It allows customization of style, visibility, and child clipping. ```dart LiquidGlassLens({ LiquidGlassStyle style = const LiquidGlassStyle(), bool visibility = true, // instant show/hide; hidden = no backdrop cost bool? useImpellerBackdrop, // override engine auto-detection Widget? child, // clipped to the lens shape }) ``` -------------------------------- ### LiquidGlassShape Constructors Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Provides constructors for defining the shape of the liquid glass, with options for rounded rectangles, squircles, and continuous rounded rectangles. ```APIDOC ## `LiquidGlassShape` Constructors ### Description Provides constructors to define the shape of the liquid glass lens, offering different corner styles and customization options. ### Constructors - **`LiquidGlassShape.roundedRectangle(...)`**: Creates a shape with plain circular corners (most performant). - **`LiquidGlassShape.squircle(...)`**: Creates a shape with L^n squircle corners, similar to iOS continuous curvature. - **`LiquidGlassShape.continuousRoundedRectangle(...)`**: Creates a shape with Apple capsule-style continuous corners (default behavior). ### Common Parameters - `cornerRadius` - `borderWidth` - `borderColor` - `lightColor` - `lightIntensity` - `lightDirection` - `borderType` - `clipQuality` (`roundedRectangle` or `exact`) ``` -------------------------------- ### Standalone Bottom Navigation Bar with Impeller Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Shows how to use LiquidGlassBottomNavBar.withImpeller for standalone use without a LiquidGlassScaffold. This constructor allows the bar to sample the live backdrop on Impeller. ```dart Stack( children: [ MyPage(), LiquidGlassBottomNavBar.withImpeller( items: items, selectedIndex: index, onChanged: (i) => setState(() => index = i), ), ], ); ``` -------------------------------- ### Runtime Output Directory Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to prevent accidental execution of unbundled copies. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Executable and Application ID Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Defines the name of the executable and the unique GTK application identifier. ```cmake set(BINARY_NAME "liquid_glass_easy_example") set(APPLICATION_ID "com.example.liquid_glass_easy_example") ``` -------------------------------- ### Modern CMake Policy Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Modern CMake Policy Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Add Runner Subdirectory Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Includes the application's runner directory as a subdirectory for building. ```cmake add_subdirectory("runner") ``` -------------------------------- ### Define Static Library for Application Runner Wrapper Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Creates a static library for the C++ wrapper used by the Flutter application runner. It includes core and application-specific source files and links against the Flutter library. ```cmake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Define Build Configuration Types Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Sets the available build configuration types (Debug, Profile, Release) based on whether the generator is multi-configuration. ```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() ``` -------------------------------- ### Add Preprocessor Definitions Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/runner/CMakeLists.txt Adds preprocessor definitions to the build, specifically for the application ID. This is useful for conditionally compiling code based on the application's identifier. ```cmake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Configure Flutter interface library Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library target named 'flutter' and sets its include directories and link libraries. This includes the Flutter engine library and GTK/GLIB/GIO. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}" PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) ``` -------------------------------- ### Defining a LiquidGlassStyle Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Shows how to define a reusable LiquidGlassStyle with shape, appearance, and refraction properties. ```dart const LiquidGlassStyle( shape: LiquidGlassShape.continuousRoundedRectangle(cornerRadius: 24), appearance: LiquidGlassAppearance(color: Color(0x22FFFFFF)), refraction: LiquidGlassRefraction(distortion: 0.08, distortionWidth: 28), ); ``` -------------------------------- ### Link Dependency Libraries Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/runner/CMakeLists.txt Links the necessary libraries for the application target. 'flutter' and 'PkgConfig::GTK' are added as private dependencies. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Glass Slider and Toggle Components Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Demonstrates the basic usage of LiquidGlassSlider and LiquidGlassToggle. These components are self-contained and styled using LiquidGlassStyle. ```dart // A glass slider with a jelly thumb that refracts the track. LiquidGlassSlider( value: volume, onChanged: (v) => setState(() => volume = v), ); // A glass toggle. LiquidGlassToggle( value: wifi, activeColor: const Color(0xFF0A84FF), onChanged: (v) => setState(() => wifi = v), ); ``` -------------------------------- ### Build Type Configuration Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already specified, and enforces allowed values. ```cmake if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Define list_prepend function in CMake Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/flutter/CMakeLists.txt This function prepends a prefix to each element in a list. It's a workaround for older CMake versions that lack the list(TRANSFORM ... PREPEND ...) command. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Add Flutter Subdirectory Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/CMakeLists.txt Includes the Flutter SDK's managed directory as a subdirectory for building. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Define Executable Target Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/runner/CMakeLists.txt Defines the main executable target for the application. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` compatibility. Add any new source files to this list. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### LiquidGlassStyle Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Defines the constructor for LiquidGlassStyle, allowing customization of shape, appearance, and refraction. ```dart LiquidGlassStyle({ LiquidGlassShape? shape, // null → default continuous rounded rect LiquidGlassAppearance appearance = const LiquidGlassAppearance(), LiquidGlassRefraction refraction = const LiquidGlassRefraction(), }) ``` -------------------------------- ### Configure Classic Border Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Use ClassicBorder for a classic light/shadow sweep effect. Customize light and shadow colors, and border softness for depth and style. ```dart LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.roundedRectangle( lightColor: Color(0xB2FFFFFF), borderType: ClassicBorder( borderSoftness: 2.5, shadowColor: Color(0x1A000000), ), ), ), ) ``` -------------------------------- ### LiquidGlassStyle Constructor Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Defines the visual style of the liquid glass effect, including shape, appearance, and refraction properties. ```APIDOC ## `LiquidGlassStyle` Constructor ### Description Defines the visual style for the liquid glass effect. It allows customization of the shape, appearance (color, blur, saturation), and refraction properties. ### Parameters #### Named Parameters - **shape** (`LiquidGlassShape?`) - Optional - Defines the shape of the lens. If null, a default continuous rounded rectangle is used. - **appearance** (`LiquidGlassAppearance`) - Optional - Defines the visual appearance, including color, blur, and saturation. Defaults to `LiquidGlassAppearance()`. - **refraction** (`LiquidGlassRefraction`) - Optional - Defines the refraction properties like distortion and magnification. Defaults to `LiquidGlassRefraction()`. ``` -------------------------------- ### Configure Flutter Library Interface Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Defines an INTERFACE library for Flutter, setting include directories and linking against the Flutter library. It also adds a dependency on flutter_assemble. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### LiquidGlassAppearance Properties Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Defines the appearance of the liquid glass, including base color, blur effects, saturation, and transparency settings. ```APIDOC ## `LiquidGlassAppearance` Properties ### Description Defines the visual appearance of the liquid glass, including its base color, blur intensity, saturation level, and transparency of the inner region. ### Properties - **color** (`dynamic`) - Optional - The base tint of the lens, often semi-transparent. Defaults to `transparent`. - **blur** (`dynamic`) - Optional - The blur effect applied to the content beneath the glass. Defaults to `LiquidGlassBlur()`. - **saturation** (`double`) - Optional - Controls the saturation of the content seen through the lens. `1.0` is unchanged, `0.0` is grayscale. Defaults to `1.0`. - **enableInnerRadiusTransparent** (`bool`) - Optional - If true, the inner, non-distorted region of the lens is transparent. Defaults to `false`. ``` -------------------------------- ### LiquidGlassAppearance Properties Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Details the properties available for LiquidGlassAppearance, controlling base color, blur, saturation, and transparency. ```dart LiquidGlassAppearance({ Color color = Colors.transparent, LiquidGlassBlur? blur, // Blur applied to content beneath the glass. double saturation = 1.0, // `1.0` = unchanged, `0.0` = grayscale. bool enableInnerRadiusTransparent = false, // Whether the inner, non-distorted region is transparent. }) ``` -------------------------------- ### Define Flutter Assemble Custom Target Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the output of the Flutter tool backend command, ensuring all necessary Flutter artifacts are built. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Flutter Assemble Dependency Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/CMakeLists.txt Ensures that the application executable depends on the flutter_assemble target. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### LiquidGlassRefraction Properties Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Configures the refraction properties of the liquid glass, controlling distortion, magnification, and chromatic aberration. ```APIDOC ## `LiquidGlassRefraction` Properties ### Description Configures the refraction properties of the liquid glass, affecting how content is distorted and magnified when viewed through the lens. ### Properties - **distortion** (`double`) - Optional - Bending strength of the distortion, ranging from `0.0` to `1.0`. Defaults to `0.1`. - **distortionWidth** (`double`) - Optional - Thickness of the distortion band around the perimeter in pixels. Defaults to `30`. - **magnification** (`double`) - Optional - Magnification of content seen through the lens. `1.0` means no magnification. Defaults to `1.0`. - **chromaticAberration** (`double`) - Optional - Color-channel separation effect. `0.0` disables it. Defaults to `0.003`. - **refractionMode** (`dynamic`) - Optional - Determines how refraction is applied. Can be `shapeRefraction` (follows shape contours) or `radialRefraction` (circular pattern). Defaults to `shapeRefraction`. ``` -------------------------------- ### Define flutter_assemble custom target Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/example/linux/flutter/CMakeLists.txt Creates a custom target 'flutter_assemble' that depends on the generated Flutter library and its headers. This ensures these artifacts are built. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### LiquidGlassRefraction Properties Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Details the properties available for LiquidGlassRefraction, controlling distortion, magnification, and chromatic aberration. ```dart LiquidGlassRefraction({ double distortion = 0.1, // Bending strength of the distortion (`0.0`–`1.0`). double distortionWidth = 30, // Thickness of the distortion band around the perimeter, in px. double magnification = 1.0, // Magnification of content seen through the lens (`1.0` = none). double chromaticAberration = 0.003, // Color-channel separation; `0.0` disables it. RefractionMode refractionMode = shapeRefraction, // `shapeRefraction` (follows shape contours) or `radialRefraction` (circular pattern). }) ``` -------------------------------- ### Create a Draggable Lens Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Use LiquidGlassDraggable to make a lens element draggable. The child widget is wrapped by the lens and can be customized with styles like shape and refraction. ```dart LiquidGlassDraggable( child: SizedBox( width: 200, height: 200, child: LiquidGlassLens( style: const LiquidGlassStyle( shape: LiquidGlassShape.roundedRectangle(cornerRadius: 100), refraction: LiquidGlassRefraction(distortion: 0.2, magnification: 1.1), ), child: const Center(child: Text('drag me')), ), ), ) ``` -------------------------------- ### Control Lens Visibility Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md Manage the visibility of a LiquidGlassLens using the 'visibility' property. Setting it to false instantly disables the glass effect and removes the child. ```dart LiquidGlassLens(visibility: _visible, style: myStyle, child: content) ``` -------------------------------- ### Disable Overscroll for Scrollables with Lenses (Impeller) Source: https://github.com/ahmeedgamil/liquid_glass_easy/blob/main/README.md When using LiquidGlassLens inside scrollables on Impeller (Android), disable the overscroll indicator to prevent backdrop lenses from rendering black at scroll edges. This is crucial for correct rendering. ```dart ScrollConfiguration( behavior: const MaterialScrollBehavior().copyWith(overscroll: false), child: ListView(children: [ /* ...LiquidGlassLens... */ ]), ) ```