win32
6.4.0, released 4 months ago by halildurmus.dev
Call common Windows APIs and COM objects directly from Dart using FFI.
What it does
Exposes a curated surface of Win32 and COM APIs via Dart FFI. Enables Windows-specific capabilities that are not accessible through standard dart:io or Flutter plugins.
AI-written summary of version 6.4.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Building Flutter desktop apps for Windows that require low-level system or hardware access.
- Writing cross-platform packages with a Windows-specific native backend.
- Developing command-line tools or background services on Windows needing native file, process, or security APIs.
Skip it when
- Targeting non-Windows platforms like Android, iOS, or macOS.
- Building standard multiplatform apps where regular Flutter plugins or dart:io provide sufficient functionality.
Strengths
- Provides direct, low-level access to Win32 and COM APIs in Dart.
- Eliminates the need for MSVC to build native wrappers in recent versions.
- Supports robust error handling and modern FFI usage.
Weaknesses
- Restricted entirely to the Windows platform.
- Requires manual resource management and dealing with raw platform pointers.
Setup
- Kind
- FFI (native library)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Works out of the box on Windows targets; no local MSVC compiler is strictly required for default prebuilt binaries.
import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart';
void main() {
using((arena) {
final Win32Result(:value, :error) = MessageBox(
null,
arena.pcwstr('Hello from Dart'),
arena.pcwstr('Dart Win32 MessageBox Demo'),
MB_OK | MB_ICONINFORMATION,
);
switch (value) {
case IDOK:
print('OK pressed');
case 0:
throw WindowsException(error.toHRESULT());
}
});
}Alternatives
Packages that do the same job and could replace win32.
- window_manager
If you only need window management and desktop framing features rather than raw Win32 bindings.
93Compare
Works with
Packages commonly used together with win32: ones it builds on, ones built on it, and its own family.
- ffiwin32 depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- ffi_leak_trackerwin32 depends on itTracks and detects native memory leaks in Dart FFI allocations.
- package_info_plusBuilt on win32Flutter plugin to query app package info like version, build number and installer store.
- share_plusBuilt on win32Share text, files, or URIs via native share dialogs on mobile, web, and desktop.
- device_info_plusBuilt on win32Provides detailed information about the current device, make, model, and OS version.
- win32_registryBuilt on win32Type‑safe Dart API for accessing and managing the Windows Registry
- wakelock_plusBuilt on win32Keep the device screen awake across mobile, desktop, and web platforms.
- mason_loggerBuilt on win32A lightweight CLI logger with prompts, progress, and custom styling.