### CMake Installation Rules for Windows Executable Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/windows/CMakeLists.txt Configures the installation process for the Windows build. It sets the installation prefix to be adjacent to the executable, making the application runnable in place. It then installs the executable, ICU data, Flutter library, bundled plugin libraries, and native assets. ```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(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() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Basic Setup with AntdProvider in Flutter Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Demonstrates the basic setup of an Antd Flutter Mobile application. The `AntdProvider` widget is essential for providing theme and token configurations throughout the widget tree. It also shows the necessary `navigatorObservers` for overlay components. ```dart import 'package:antd_flutter_mobile/index.dart'; import 'package:flutter/material.dart'; void main() { runApp(AntdProvider( theme: AntdTheme( mode: AntdThemeMode.light, token: const AntdSeedToken( colorPrimary: Color(0xff1677ff), colorSuccess: Color(0xff00b578), colorWarning: Color(0xffff8f1f), colorError: Color(0xffff3141), fontSize: 14, radius: 6, ), ), builder: (context, theme) { return MaterialApp( navigatorObservers: [AntdLayer.observer], // Required for overlay components home: const MyHomePage(), ); }, )); } ``` -------------------------------- ### Basic Antd Button Example (Dart) Source: https://github.com/opensourcenocode/antd-flutter/blob/main/README.md Demonstrates the basic usage of the AntdButton component in a Flutter application. This example requires the 'antd_flutter_mobile' package and 'flutter/material.dart'. It renders a simple button centered on the screen. ```dart import 'package:antd_flutter_mobile/index.dart'; import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( builder: (context, child) { return const Center( child: AntdButton( child: Text("Button"), ), ); }, )); } ``` -------------------------------- ### AntdBox Component Examples Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Illustrates the usage of the `AntdBox` component, a versatile layout container. Examples cover basic styling, tap feedback effects, safe area handling for notches, layout callbacks for size detection, and utilizing numeric extensions for concise styling. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic styled container AntdBox( style: AntdBoxStyle( color: Colors.blue, padding: EdgeInsets.all(16), radius: BorderRadius.circular(8), width: 200, height: 100, ), child: const Text('Styled Box'), ) // Container with tap feedback effect AntdBox( style: AntdBoxStyle( color: token.colorBgContainer, feedbackStyle: AntdBoxStyle(color: token.colorFillTertiary), padding: 16.all, radius: token.radius.all, ), onTap: () => print('Box tapped'), child: const Text('Tap me'), ) // Container with safe area handling (notch/home indicator) AntdBox( outerSafeArea: AntdPosition.top, innerSafeArea: AntdPosition.bottom, style: AntdBoxStyle(color: Colors.white), child: const Text('Safe content'), ) // Layout callback for size detection AntdBox( onLayout: (context) { print('Size: ${context.renderBox.size}'); print('Has size change: ${context.hasSizeChange}'); }, child: const Text('Observable box'), ) // Using numeric extensions for styling AntdBox( style: AntdBoxStyle( padding: 16.vertical.marge(24.horizontal), margin: 8.all, border: token.border.bottom, radius: 12.radius.all, ), child: const Text('Extension styled'), ) ``` -------------------------------- ### Antd Toast Example with Layer (Dart) Source: https://github.com/opensourcenocode/antd-flutter/blob/main/README.md Illustrates how to use AntdToast with AntdLayer for managing navigation and displaying toast messages. This example requires 'antd_flutter_mobile' and 'flutter/material.dart'. It shows a button that triggers a toast message when tapped. ```dart import 'package:antd_flutter_mobile/index.dart'; import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( navigatorObservers: [AntdLayer.observer], home: AntdTokenBuilder(builder: (context, token) { return AntdBox( style: AntdBoxStyle(color: token.colorFillTertiary, alignment: Alignment.center), child: AntdButton( onTap: () { AntdToast.show( "Toast", position: AntdToastPosition.top, ); }, child: const Text("Button"), ), ); }), )); } ``` -------------------------------- ### Install Antd Flutter Mobile Source: https://github.com/opensourcenocode/antd-flutter/blob/main/README.md This command adds the antd_flutter_mobile package to your Flutter project's dependencies. Ensure you have Flutter installed and configured. ```bash flutter pub add antd_flutter_mobile ``` -------------------------------- ### AntdImage Component Examples (Dart) Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Demonstrates the usage of the AntdImage component for displaying network and asset images, with options for custom styling, sizing, and alignment. It handles loading and error states implicitly. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic image from network AntdImage( image: NetworkImage('https://example.com/photo.jpg'), width: 200, height: 150, fit: BoxFit.cover, ) // Image from asset AntdImage( image: const AssetImage('assets/images/logo.png'), width: 100, height: 100, ) // Image with custom styling AntdImage( image: NetworkImage('https://example.com/avatar.jpg'), width: 80, height: 80, style: AntdImageStyle( bodyStyle: AntdBoxStyle( radius: BorderRadius.circular(40), // Circular image ), ), ) // Image with alignment AntdImage( image: NetworkImage('https://example.com/banner.jpg'), width: double.infinity, height: 200, fit: BoxFit.cover, alignment: Alignment.topCenter, ) ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It cleans the build bundle directory, installs the executable, Flutter ICU data, Flutter library, bundled plugin libraries, and native assets to their respective destinations within the bundle. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() 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) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets in CMake Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Configures the installation of Flutter assets, including removing previous installations and copying new assets to the destination directory. This is crucial for ensuring the application has the necessary resources at runtime. ```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) ``` -------------------------------- ### AntdButton Component Examples Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Showcases various configurations and use cases for the `AntdButton` component. This includes basic tap handling, different color and fill modes, shapes, icon integration, automatic loading states for async operations, and block-level buttons. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic button with tap handler AntdButton( onTap: () { print('Button tapped'); }, child: const Text('Default Button'), ) // Primary colored button with solid fill AntdButton( color: AntdColor.primary, fill: AntdButtonFill.solid, onTap: () => print('Primary action'), child: const Text('Primary Button'), ) // Outlined button with rounded shape AntdButton( fill: AntdButtonFill.outline, shape: AntdButtonShape.rounded, color: AntdColor.success, child: const Text('Success Outline'), ) // Large button with icon AntdButton( size: AntdSize.large, icon: const AntdIcon(icon: AntdIcons.add), child: const Text('Add Item'), ) // Button with automatic loading state for async operations AntdButton( onLoadingTap: () async { await Future.delayed(const Duration(seconds: 2)); // Loading indicator shows automatically during async execution }, child: const Text('Submit'), ) // Block-level button (full width) AntdButton( block: true, color: AntdColor.danger, disabled: false, onTap: () => print('Delete action'), child: const Text('Delete'), ) ``` -------------------------------- ### AntdTabs Component Examples in Dart Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Illustrates the AntdTabs component for creating tabbed navigation interfaces. It supports customizable indicators, haptic feedback, and programmatic control via a controller. Dependencies include 'antd_flutter_mobile/index.dart'. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic tabs with content panels AntdTabs( tabs: [ AntdTab( title: const Text('Home'), value: 'home', child: const Center(child: Text('Home Content')), ), AntdTab( title: const Text('Profile'), value: 'profile', child: const Center(child: Text('Profile Content')), ), AntdTab( title: const Text('Settings'), value: 'settings', child: const Center(child: Text('Settings Content')), ), ], ) // Tabs with change callback AntdTabs( activeValue: 'home', onChange: (value, index) { print('Selected: $value at index $index'); }, tabs: [ AntdTab(title: const Text('Tab 1'), value: 'tab1'), AntdTab(title: const Text('Tab 2'), value: 'tab2'), AntdTab(title: const Text('Tab 3'), value: 'tab3'), ], ) // Tabs with controller for programmatic control final tabController = AntdTabController(); AntdTabs( controller: tabController, tabs: [ AntdTab(title: const Text('First'), value: 0), AntdTab(title: const Text('Second'), value: 1), AntdTab(title: const Text('Third'), value: 2), ], ) // Switch programmatically tabController.switchTo(2); // Tabs with left/right extra content AntdTabs( leftExtra: const AntdIcon(icon: AntdIcons.filter), rightExtra: AntdButton( onTap: () => print('Add'), child: const AntdIcon(icon: AntdIcons.add), ), tabs: myTabs, ) // Tabs with disabled item AntdTabs( tabs: [ AntdTab(title: const Text('Active'), value: 'active'), AntdTab(title: const Text('Disabled'), value: 'disabled', disabled: true), ], ) ``` -------------------------------- ### Configuring AntdInput for Data Entry Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Provides examples for creating text inputs with features like clear buttons, password visibility toggles, prefix/suffix decorations, and multiline support. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic input with placeholder AntdInput( placeholder: const Text('Enter text'), onChange: (value) => print('Value: $value'), ) // Input with controller final controller = AntdInputController(); AntdInput( controller: controller, placeholder: const Text('Controlled input'), onSubmitted: (value) => print('Submitted: $value'), ) // Password input with visibility toggle AntdInput( obscureText: true, obscureIcon: true, // Shows eye icon to toggle visibility placeholder: const Text('Password'), onChange: (value) => print('Password: $value'), ) // Input with clear button (default enabled) AntdInput( clearable: true, onClear: () => print('Input cleared'), placeholder: const Text('Clearable input'), ) // Input with prefix and suffix AntdInput( prefix: const AntdIcon(icon: AntdIcons.search), suffix: const Text('USD'), placeholder: const Text('Amount'), keyboardType: TextInputType.number, ) // Multiline input AntdInput( maxLines: 4, minLines: 2, placeholder: const Text('Enter description'), ) // Input with max length AntdInput( maxLength: 100, placeholder: const Text('Limited to 100 characters'), ) // Read-only and disabled states AntdInput( readOnly: true, value: 'Read only value', ) AntdInput( disabled: true, placeholder: const Text('Disabled input'), ) ``` -------------------------------- ### Implement Antd Flutter Style System with Dart Source: https://github.com/opensourcenocode/antd-flutter/blob/main/README.md This Dart code snippet demonstrates the Antd-Flutter style system. It shows how to use AntdStyleBuilderProvider, AntdStyleProvider, and AntdBoxStyle to customize the appearance of UI elements like AntdBox. The example highlights nested styling and builder patterns for dynamic style application. ```dart import 'package:antd_flutter_mobile/index.dart'; import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( home: AntdStyleBuilderProvider( /// 1 builder: (context, box, style, token,) { return AntdBoxStyle( color: token.colorPrimary, size: 100, textStyle: token.font.md.copyWith(color: token.colorSuccess), alignment: Alignment.center); }, child: Row( children: [ AntdStyleProvider( /// 2 style: const AntdBoxStyle(size: 50), child: AntdBox( /// 4 style: AntdBoxStyle( radius: 10.radius.all, textStyle: const TextStyle(color: Colors.white)), /// 3 styleBuilder: (context, box, style, token,) { return AntdBoxStyle( border: token.border .copyWith(color: token.colorSuccess, width: 3) .all); }, child: const Text("box1"), )), AntdBox( style: AntdBoxStyle(margin: 10.left), child: const Text("box2"), ) ], )), )); } ``` -------------------------------- ### AntdList Component Examples in Dart Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Demonstrates the AntdList component for creating high-performance lists with features like virtual scrolling, index jumping, and position monitoring. It supports various item types, headers, footers, and card-style layouts. Dependencies include 'antd_flutter_mobile/index.dart'. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic list with widget items AntdList( items: [ const Text('Item 1'), const Text('Item 2'), const Text('Item 3'), ], ) // List with header and footer AntdList( header: const Text('My List'), footer: const Text('End of list'), items: ['Apple', 'Banana', 'Cherry'], itemBuilder: (ctx) => Text(ctx.data), ) // Card-style list AntdList>( card: true, feedback: true, // Enable tap feedback items: [ {'title': 'Settings', 'subtitle': 'App preferences'}, {'title': 'Profile', 'subtitle': 'User information'}, ], itemBuilder: (ctx) => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(ctx.data['title']!), Text(ctx.data['subtitle']!), ], ), ) // Virtual scrolling for large datasets final listController = AntdListController(); AntdList( controller: listController, virtual: true, // Enable virtual scrolling items: List.generate(10000, (i) => i), itemBuilder: (ctx) => Text('Item ${ctx.data}'), onItemPosition: (ctx) { if (ctx.isFirstAppear) { print('Visible: ${ctx.index}'); } }, ) // Jump to specific index listController.toIndex(500); // Edge detection for infinite scroll AntdList( items: items, edgeThreshold: 100, onEdgeReached: (edge) { if (edge == AntdEdge.bottom) { loadMoreItems(); } }, itemBuilder: (ctx) => Text('Item ${ctx.data}'), ) ``` -------------------------------- ### Utilize Dialogs with AntdDialog in Dart Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Explains how to use the AntdDialog component for user decisions, featuring different action button layouts and styles. Includes examples for basic dialogs, alerts, confirmation dialogs, and dialogs with danger actions. ```dart import 'package:antd_flutter_mobile/index.dart'; // Show dialog with content AntdDialog.show( title: const Text('Dialog Title'), content: const Text('Dialog content goes here'), actions: [ AntdDialogAction( title: const Text('Confirm'), primary: true, onTap: (close) => close(), ), ], ); // Alert dialog AntdDialog.alert( const Text('Operation completed successfully'), title: const Text('Success'), onConfirm: (close) async { await close(); }, ); // Confirm dialog with bottom button layout AntdDialog.confirm( const Text('Do you want to proceed with this action?'), title: const Text('Confirmation'), confirm: const Text('Yes'), cancel: const Text('No'), onConfirm: (close) async { await performAction(); await close(); }, onCancel: (close) async { await close(); }, ); // Dialog with danger action AntdDialog( title: const Text('Delete Item'), builder: (close, state) => const Text('This cannot be undone.'), actions: [ AntdDialogAction( title: const Text('Cancel'), bottom: true, primary: false, onTap: (close) => close(), ), AntdDialogAction( title: const Text('Delete'), bottom: true, danger: true, onTap: (close) async { await deleteItem(); await close(); }, ), ], ).open(); ``` -------------------------------- ### Install AOT Library Conditionally in CMake Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-Debug builds. This ensures that performance-critical libraries are available in release configurations, improving application speed. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Custom Theme for Antd Components (Dart) Source: https://github.com/opensourcenocode/antd-flutter/blob/main/README.md Shows how to customize the theme of Antd components using AntdProvider and AntdTheme. This example requires 'antd_flutter_mobile' and 'flutter/material.dart'. It defines custom styles for buttons, including a warning color for large buttons. ```dart import 'package:antd_flutter_mobile/index.dart'; import 'package:flutter/material.dart'; void main() { runApp(AntdProvider( theme: AntdTheme( mode: AntdThemeMode.light, buttonStyle: (context, button, style, token) { if (button.size == AntdSize.large) { return AntdButtonStyle(buttonStyle: AntdBoxStyle(color: token.colorWarning)); } return style; }, token: const AntdSeedToken( radius: 6, colorError: Color(0xffff3141), colorInfo: Color(0xff1677ff), colorLink: Color(0xff1677ff), colorPrimary: Color(0xffad05ef), colorSuccess: Color(0xff00b578), colorText: Color(0xff171717), colorBgBase: Color(0xffffffff), colorWarning: Color(0xffff8f1f), fontSize: 14, lineWidth: 2, sizeStep: 4, sizeUnit: 2, arrow: Size(16, 8), )), builder: (context, theme) { return MaterialApp( builder: (context, child) { return const Column( mainAxisAlignment: MainAxisAlignment.center, children: [ AntdButton( child: Text("Pick Button"), ), AntdButton( size: AntdSize.large, child: Text("Waining Button"), ) ], ); }, ); })); } ``` -------------------------------- ### CMake Project Configuration and Settings Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Configures the CMake project, sets the binary name and application ID, enables modern CMake policies, and defines installation paths for libraries. It also handles build type selection (Debug, Profile, Release) and sets up the sysroot for cross-compiling. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.opensourcenocode.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 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() 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() ``` -------------------------------- ### AntdSwiper Component Examples in Dart Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Details the AntdSwiper component, a carousel/swiper for rotating content. It includes features like autoplay, vertical orientation, programmatic control, custom indicators, and disabling touch scrolling. Dependencies include 'antd_flutter_mobile/index.dart'. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic swiper with images AntdSwiper( items: [ Image.network('https://example.com/image1.jpg'), Image.network('https://example.com/image2.jpg'), Image.network('https://example.com/image3.jpg'), ], ) // Swiper with autoplay AntdSwiper( autoplay: true, autoplayInterval: const Duration(milliseconds: 3000), items: bannerImages, ) // Vertical swiper AntdSwiper( vertical: true, items: verticalSlides, ) // Swiper with change callback AntdSwiper( activeIndex: 0, onChange: (index) { print('Current slide: $index'); }, items: slides, ) // Swiper with controller final swiperController = AntdSwiperController(); AntdSwiper( controller: swiperController, items: slides, ) // Navigate programmatically swiperController.next(); swiperController.previous(); swiperController.toIndex(2); // Custom indicator builder AntdSwiper( items: slides, indicatorBuilder: (index, total) { return Positioned( bottom: 10, child: Text('${index + 1} / $total'), ); }, ) // Disable touch scrolling (for button-only navigation) AntdSwiper( allowTouchMove: false, controller: swiperController, items: slides, ) ``` -------------------------------- ### CMake: Configure Flutter library and header paths Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/flutter/CMakeLists.txt This code snippet defines the path to the Flutter library (`libflutter_linux_gtk.so`) and ICU data file. It also sets up the project build directory and the AOT (Ahead-Of-Time) compiled library path, publishing these 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) ``` -------------------------------- ### Configure CSS for Preview and Syntax Highlighting Source: https://github.com/opensourcenocode/antd-flutter/blob/main/docs/docs/components/AntdInput.md This CSS configuration provides a responsive layout for mobile-style component previews and a custom dark-themed syntax highlighter for Dart code. It includes media queries for mobile responsiveness and specific selectors for Dart language constructs like keywords, types, and functions. ```css .preview-container { display: flex; gap: 24px; margin: 32px 0; align-items: start; } .phone-preview { min-width: 375px; max-width: 375px; border: 10px solid #f3f3f3; border-radius: 40px; background: #fff; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); overflow: hidden; height: 652px; width: 393px; position: sticky; top: 80px; } .prism-code { display: block; overflow-x: auto; padding: 1em; border-radius: 6px; font-family: 'Fira Code', 'Consolas', 'Monaco', monospace; font-size: 14px; line-height: 1.5; color: #d4d4d4; background: #1e1e1e; } .prism-code .hljs-keyword { color: #569cd6; font-weight: bold; } .prism-code .hljs-string { color: #ce9178; } .prism-code .hljs-function { color: #dcdcaa; } ``` -------------------------------- ### Implementing AntdPopup for Slide-in Layers Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Demonstrates how to create popup layers that slide in from various screen edges. Supports custom content, close icons, and lifecycle callbacks. ```dart import 'package:antd_flutter_mobile/index.dart'; // Bottom popup (default) AntdPopup.show( content: Container( height: 300, child: const Center(child: Text('Popup Content')), ), ); // Popup with close icon AntdPopup( position: AntdPosition.bottom, closeIcon: const AntdIcon(icon: AntdIcons.close), builder: (close, state) => Container( height: 200, child: Column( children: [ const Text('Popup with close'), AntdButton( onTap: () => close(), child: const Text('Close'), ), ], ), ), ).open(); // Right side popup AntdPopup( position: AntdPosition.right, builder: (close, state) => Container( width: 250, child: const Text('Side menu content'), ), ).open(); // Top popup AntdPopup( position: AntdPosition.top, builder: (close, state) => Container( height: 100, child: const Text('Top notification'), ), dismissOnMaskTap: true, ).open(); // Full configuration popup AntdPopup( position: AntdPosition.bottom, showMask: true, dismissOnMaskTap: true, avoidKeyboard: true, onClosed: () => print('Popup closed'), onOpened: () => print('Popup opened'), builder: (close, state) => const YourCustomWidget(), ).open(); ``` -------------------------------- ### AntdLayer Global Overlay Management (Dart) Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Illustrates how to set up and use AntdLayer for managing global overlays such as toasts, modals, and popups. It covers opening, closing specific or all layers, and closing by type or key. ```dart import 'package:antd_flutter_mobile/index.dart'; // Setup: Add observer to MaterialApp MaterialApp( navigatorObservers: [AntdLayer.observer], home: MyApp(), ) // Open custom layer AntdLayer.open( MyCustomOverlayWidget(), layerType: 'custom', ); // Close specific layer by widget AntdLayer.closeSingle(myWidget); // Close all layers of a type AntdLayer.closeByType('toast'); // Close all layers AntdLayer.closeAll(); // Close layer by key AntdLayer.closeByKey(const Key('myLayer')); ``` -------------------------------- ### CMake: Find and check system dependencies with PkgConfig Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/flutter/CMakeLists.txt This section uses PkgConfig to find and check for required system libraries: GTK, GLIB, and GIO. It ensures these dependencies are available and configured correctly for the build. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Custom Theme Configuration with AntdProvider (Dart) Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Shows how to configure global theming in an Ant Design Flutter application using AntdProvider. This includes setting seed tokens for colors, typography, spacing, and defining component-specific style overrides. ```dart import 'package:antd_flutter_mobile/index.dart'; AntdProvider( theme: AntdTheme( mode: AntdThemeMode.light, // or AntdThemeMode.dark token: const AntdSeedToken( // Color palette colorPrimary: Color(0xff1677ff), colorSuccess: Color(0xff00b578), colorWarning: Color(0xffff8f1f), colorError: Color(0xffff3141), colorInfo: Color(0xff1677ff), colorLink: Color(0xff1677ff), colorText: Color(0xff171717), colorBgBase: Color(0xffffffff), // Typography fontSize: 14, // Spacing and sizing radius: 6, lineWidth: 1, sizeStep: 4, sizeUnit: 2, // Arrow size (for popovers, tooltips) arrow: Size(16, 8), ), // Component-specific style overrides buttonStyle: (context, button, style, token) { if (button.size == AntdSize.large) { return AntdButtonStyle( buttonStyle: AntdBoxStyle(color: token.colorWarning), ); } return style; }, inputStyle: (context, input, style, token) { return style.copyFrom(AntdInputStyle( bodyStyle: AntdBoxStyle( border: token.border.all, radius: token.radius.all, ), )); }, ), builder: (context, theme) { return MaterialApp( navigatorObservers: [AntdLayer.observer], home: const MyApp(), ); }, ) // Access token in components AntdTokenBuilder(builder: (context, token) { return AntdBox( style: AntdBoxStyle( color: token.colorPrimary, padding: token.size.lg.all, radius: token.radius.all, textStyle: token.font.lg, ), child: const Text('Themed content'), ); }) ``` -------------------------------- ### Implement Modals with AntdModal in Dart Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Illustrates the usage of AntdModal for displaying important information or requiring user interaction. Covers simple content display, alert modals, confirmation modals, and custom modals with multiple actions. ```dart import 'package:antd_flutter_mobile/index.dart'; // Simple modal with content AntdModal.show( title: const Text('Title'), content: const Text('This is the modal content.'), actions: [ AntdModalAction( title: const Text('OK'), primary: true, onTap: (close) => close(), ), ], ); // Alert modal (single button acknowledgment) AntdModal.alert( const Text('Your changes have been saved.'), title: const Text('Success'), alert: const Text('Got it'), onConfirm: (close) async { await close(); }, ); // Confirm modal (cancel/confirm buttons) AntdModal.confirm( const Text('Are you sure you want to delete this item?'), title: const Text('Confirm Delete'), confirm: const Text('Delete'), cancel: const Text('Cancel'), onConfirm: (close) async { await performDelete(); await close(); }, onCancel: (close) async { await close(); }, ); // Custom modal with multiple actions AntdModal( title: const Text('Choose Action'), dismissOnMaskTap: false, builder: (close, state) => const Text('Select an option below'), actions: [ AntdModalAction( title: const Text('Option A'), onTap: (close) => handleOptionA(), ), AntdModalAction( title: const Text('Option B'), onTap: (close) => handleOptionB(), ), AntdModalAction( title: const Text('Cancel'), danger: true, onTap: (close) => close(), ), ], ).open(); ``` -------------------------------- ### Execute Flutter Tool Backend via Custom Command Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/windows/flutter/CMakeLists.txt Defines a custom build command to invoke the Flutter tool backend script. This ensures that necessary assets and library files are generated or updated during the build process. ```cmake 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 ) ``` -------------------------------- ### Managing Forms with AntdForm and AntdFormItem Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Shows how to implement a high-performance form system using AntdFormController for validation, field state tracking, and submission handling. ```dart import 'package:antd_flutter_mobile/index.dart'; // Basic form with validation final formController = AntdFormController(); AntdForm( controller: formController, initialValues: {'username': '', 'email': ''}, onFinish: (values, errors) { if (errors.isEmpty) { print('Form submitted: $values'); } else { print('Validation errors: $errors'); } }, onValuesChange: (controller, changedValues) { print('Changed: $changedValues'); }, builder: (controller) => Column( children: [ // Username field with validation AntdFormItem( name: 'username', label: const Text('Username'), required: true, rules: [ AntdFormRule(required: true, message: 'Username is required'), AntdFormRule(min: 3, message: 'At least 3 characters'), ], builder: (ctx) => AntdInput( value: ctx.value, onChange: ctx.onChange, placeholder: const Text('Enter username'), ), ), // Email field AntdFormItem( name: 'email', label: const Text('Email'), rules: [ AntdFormRule(type: AntdFormRuleType.email, message: 'Invalid email'), ], builder: (ctx) => AntdInput( value: ctx.value, onChange: ctx.onChange, keyboardType: TextInputType.emailAddress, placeholder: const Text('Enter email'), ), ), // Submit button AntdButton( block: true, color: AntdColor.primary, onTap: () => formController.submit(), child: const Text('Submit'), ), ], ), ) // Form controller operations formController.setFieldValue('username', 'john_doe'); formController.setFieldsValue({'username': 'john', 'email': 'john@example.com'}); final values = formController.getFieldsValue(); final isValid = await formController.validateFields(); formController.resetFields(); ``` -------------------------------- ### Antd Flutter Mobile Style System Customization Source: https://context7.com/opensourcenocode/antd-flutter/llms.txt Demonstrates the cascading nature of styles in Antd Flutter Mobile, showing how styles are applied with priority from widget-specific to provider-level. It illustrates overriding styles and using inherited styles. ```dart import 'package:antd_flutter_mobile/index.dart'; // Style provider for inherited styles AntdStyleProvider( style: const AntdBoxStyle( color: Colors.blue, padding: EdgeInsets.all(16), ), child: Column( children: [ // Inherits styles from provider AntdBox(child: const Text('Inherited style')), // Override with local style AntdBox( style: const AntdBoxStyle(color: Colors.red), child: const Text('Overridden color'), ), ], ), ) // Style builder provider for dynamic styles AntdStyleBuilderProvider( builder: (context, box, style, token) { return AntdBoxStyle( color: token.colorPrimary, textStyle: token.font.md, padding: token.size.lg.all, ); }, child: AntdBox( // Uses styles from builder styleBuilder: (context, box, style, token) { // Additional style modifications return AntdBoxStyle( border: token.border.all, ); }, child: const Text('Dynamic styled'), ), ) // Using numeric extensions AntdBox( style: AntdBoxStyle( padding: 16.all, // EdgeInsets.all(16) margin: 8.vertical, // EdgeInsets.symmetric(vertical: 8) radius: 12.radius.all, // BorderRadius.circular(12) border: token.border.bottom, // Border on bottom only ), ) ``` -------------------------------- ### CMake: Define and prepend Flutter library headers Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/flutter/CMakeLists.txt This section lists the necessary Flutter header files and uses the custom `list_prepend` function to add the Flutter ephemeral directory prefix to each header path. This ensures the compiler can locate the header files. ```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/") ``` -------------------------------- ### Configure Flutter Library and Wrapper Targets in CMake Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/windows/flutter/CMakeLists.txt Sets up the interface library for the Flutter Windows DLL and defines static libraries for the C++ wrapper components. It includes source file management and target property configuration for plugin and application wrappers. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}") target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) 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) 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) ``` -------------------------------- ### Configure Flutter Windows Application Build with CMake Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/windows/runner/CMakeLists.txt This CMake configuration defines the executable target for a Flutter Windows application. It includes essential source files, applies standard build settings, sets versioning preprocessor definitions, and links the required Flutter and system libraries. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) apply_standard_settings(${BINARY_NAME}) target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 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}") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Executable Definition and Linking Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Defines the main application executable target, including source files from the project and generated Flutter plugin registration. It applies standard build settings and links necessary libraries such as Flutter and GTK. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake: Define custom command for Flutter tool backend Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/flutter/CMakeLists.txt This custom command invokes the Flutter tool backend script to build the Flutter library and headers. It uses a phony output file to ensure the command runs on every build, as direct input/output tracking for the tool is not yet supported. ```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. 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 ) ``` -------------------------------- ### CMake Function for Standard Build Settings Source: https://github.com/opensourcenocode/antd-flutter/blob/main/example/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features and options to a target. It sets the C++ standard to C++14, enables all warnings, treats warnings as errors, and applies optimization and NDEBUG definitions based on the build configuration. ```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() ```