Skip to content
pubscout

win32

6.4.0, released 4 months ago by halildurmus.dev

Call common Windows APIs and COM objects directly from Dart using FFI.

Flutter Favorite
$ flutter pub add win32
Source repository

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.

Works with

Packages commonly used together with win32: ones it builds on, ones built on it, and its own family.