Skip to content

feat(dart): add opt-in WinUI 3 backend support to cnativeapi build hook (#63) - #70

Merged
lijy91 merged 1 commit into
mainfrom
feat/issue-63
Dec 1, 2026
Merged

lijy91 merged 1 commit into
mainfrom
feat/issue-63

Conversation

@lijy91

@lijy91 lijy91 commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #63.

Adds an opt-in hooks.user_defines.cnativeapi.winui3 boolean flag (false by default) to bindings/dart/cnativeapi/hook/build.dart so Dart and Flutter apps on Windows can enable nativeapi-core's WinUI 3 backend (ContentDialog message dialogs, MenuFlyout menus, WinUI 3 views, AppWindow title-bar colors, and AppNotifications):

hooks:
  user_defines:
    cnativeapi:
      winui3: true

When enabled on Windows (OS.windows):

  1. Restores the pinned Windows App SDK 1.6, C++/WinRT, and WebView2 NuGet packages once into outputDirectoryShared via cmake/RestoreWinUI3.ps1 (guarded by a stamp matching RestoreWinUI3.ps1 and tracked in output.dependencies).
  2. Validates the Windows App SDK 1.6 header version and generates C++/WinRT projection headers with cppwinrt.exe (mirroring core/cmake/WinUI3.cmake).
  3. Compiles the WinUI 3 sources (*_winui3_windows.cpp) instead of message_dialog_windows.cpp under /std:c++20 (so C++/WinRT uses standard <coroutine> on MSVC 14.52+) with NATIVEAPI_ENABLE_WINUI3, NOMINMAX, /MP, and /bigobj, and links windowsapp.
  4. Bundles the target architecture's Microsoft.WindowsAppRuntime.Bootstrap.dll (x64 / arm64 / x86) as a CodeAsset.

Default builds (winui3: false or omitted) and non-Windows builds remain unchanged.

Verification

  • Added unit tests for winui3 option validation in bindings/dart/cnativeapi/test/build_hook_test.dart.
  • Added an end-to-end Windows build-hook test compiling cnativeapi.dll with winui3: true, verifying Microsoft.WindowsAppRuntime.Bootstrap.dll bundling, and loading cnativeapi.dll via dart:ffi to confirm native_message_dialog_is_extended_supported(), native_notification_manager_is_supported(), native_menu_is_backend_supported(WINUI3), and native_view_is_backend_supported(WINUI3) all report true.
  • Documented the option and runtime prerequisites in bindings/dart/cnativeapi/README.md.

@lijy91
lijy91 force-pushed the feat/issue-63 branch 2 times, most recently from eeee17f to 4898b78 Compare December 1, 2026 02:20
@lijy91
lijy91 merged commit 46bbf86 into main Dec 1, 2026
9 checks passed
@lijy91
lijy91 deleted the feat/issue-63 branch December 1, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Opt-in WinUI 3 backend support in the Windows build hook

1 participant